1 Uebung

Dependencies:   mbed

Committer:
rob117
Date:
Tue Oct 13 16:14:18 2020 +0000
Revision:
5:a0a51cfb3981
Parent:
4:6bea8ed92ad7
ueberladener Konstruktor

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rob117 0:928e720c71da 1 #include "mbed.h"
rob117 2:3c3a6f0b11d2 2
rob117 4:6bea8ed92ad7 3 class MyClass
rob117 4:6bea8ed92ad7 4 {
rob117 4:6bea8ed92ad7 5 public:
rob117 5:a0a51cfb3981 6 MyClass() : _messwert(0) //Initialisierungsliste
rob117 4:6bea8ed92ad7 7 {
rob117 5:a0a51cfb3981 8 _messwert = 1;
rob117 4:6bea8ed92ad7 9 }
rob117 5:a0a51cfb3981 10 MyClass(double messwert) : _messwert(messwert){ //Ueberladener Konstruktor
rob117 5:a0a51cfb3981 11
rob117 5:a0a51cfb3981 12 }
rob117 5:a0a51cfb3981 13
rob117 4:6bea8ed92ad7 14 void status() //Funktion die den status von Messwert abfragt
rob117 4:6bea8ed92ad7 15 {
rob117 5:a0a51cfb3981 16 printf("messwert: %f\n", _messwert);
rob117 4:6bea8ed92ad7 17
rob117 4:6bea8ed92ad7 18 }
rob117 4:6bea8ed92ad7 19
rob117 5:a0a51cfb3981 20
rob117 5:a0a51cfb3981 21
rob117 5:a0a51cfb3981 22
rob117 4:6bea8ed92ad7 23 private:
rob117 4:6bea8ed92ad7 24 double _messwert;
rob117 4:6bea8ed92ad7 25 };
rob117 3:dbd662e5f8f8 26
rob117 2:3c3a6f0b11d2 27
rob117 5:a0a51cfb3981 28 MyClass m1;
rob117 5:a0a51cfb3981 29 MyClass m(6);
rob117 2:3c3a6f0b11d2 30
rob117 2:3c3a6f0b11d2 31 int main()
rob117 4:6bea8ed92ad7 32 {
rob117 4:6bea8ed92ad7 33 while(1) {
rob117 4:6bea8ed92ad7 34
rob117 5:a0a51cfb3981 35 m1.status();
rob117 4:6bea8ed92ad7 36 wait_ms(500);
rob117 5:a0a51cfb3981 37 m.status();
rob117 4:6bea8ed92ad7 38 }
rob117 5:a0a51cfb3981 39 }