1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
// Kapitel 2 - Programm 2 - STRUKT.CPP
#include <iostream>
struct Tier
{
int Gewicht;
int Beine;
};
int main()
{
Tier Hund1, Hund2, Henne;
Tier Katze1;
struct Tier Katze2;
Hund1.Gewicht = 15;
Hund2.Gewicht = 37;
Henne.Gewicht = 3;
Hund1.Beine = 4;
Hund2.Beine = 4;
Henne.Beine = 2;
std::cout << "Das Gewicht von Hund1 ist " << Hund1.Gewicht << "\n";
std::cout << "Das Gewicht von Hund2 ist " << Hund2.Gewicht << "\n";
std::cout << "Das Gewicht von Henne ist " << Henne.Gewicht << "\n";
return 0;
}
// Ergebnis beim Ausführen
//
// Das Gewicht von Hund1 ist 15
// Das Gewicht von Hund2 ist 37
// Das Gewicht von Henne ist 3
|
Copyright © 1997, 1998, 2001-2005 Heinz Tschabitscher - Letzte Änderung 13. September 2005
Heinz Tschabitscher - cpp@ladedu.com | Datenschutz | Impressum - Kommentare, Kritik, Anregungen, Fragen?