mirror of
https://inf-git.fh-rosenheim.de/studavrije7683/cplusplus-training.git
synced 2025-04-19 22:49:55 +00:00
45 lines
636 B
C++
45 lines
636 B
C++
#include <iostream>
|
|
#include <cstdlib>
|
|
|
|
using namespace std ;
|
|
|
|
class Person
|
|
{
|
|
private:
|
|
string vname, name;
|
|
int alter;
|
|
|
|
public:
|
|
void einlesen();
|
|
void vergleiche(Person);
|
|
};
|
|
|
|
void Person::einlesen()
|
|
{
|
|
cout << "Vorname : ";
|
|
cin >> vname ;
|
|
cout << "Name : ";
|
|
cin >> name ;
|
|
cout << "Alter : ";
|
|
cin >> alter ;
|
|
}
|
|
|
|
void Person::vergleiche(Person p)
|
|
{
|
|
if (alter > p.alter)
|
|
cout << vname << " " << name << " ist der aeltere." << endl ;
|
|
else
|
|
cout << p.vname << " " << p.name << " koennte der aeltere sein." << endl ;
|
|
}
|
|
|
|
int main ( void )
|
|
{
|
|
Person p1, p2 ;
|
|
|
|
p1.einlesen();
|
|
cout << endl ;
|
|
p2.einlesen();
|
|
|
|
p1.vergleiche(p2);
|
|
}
|