Skip to content
Snippets Groups Projects
Commit fcc5d9a3 authored by Rudi Buss's avatar Rudi Buss
Browse files

Update Solution Exercise 4 - Personal information.cpp

parent 21213ad9
No related branches found
No related tags found
No related merge requests found
......@@ -2,42 +2,38 @@
using namespace std;
class Person
{
public:
string fname, lname;
int age;
void insert();
void compare(Person);
class Person {
public:
string fname, lname;
int age;
void insert();
void compare(Person);
};
void Person::insert()
{
cout << "First name : ";
cin >> fname;
cout << "Last name : ";
cin >> lname;
cout << "Age : ";
cin >> age;
void Person::insert() {
cout << "First name : ";
cin >> fname;
cout << "Last name : ";
cin >> lname;
cout << "Age : ";
cin >> age;
}
void Person::compare(Person p)
{
if (age > p.age)
cout << fname << " " << lname << " is older." << endl;
else
cout << p.fname << " " << p.lname << " could be older." << endl;
void Person::compare(Person p) {
if (age > p.age)
cout << fname << " " << lname << " is older." << endl;
else
cout << p.fname << " " << p.lname << " could be older." << endl;
}
int main ()
{
Person p1, p2;
p1.insert();
cout << endl;
p2.insert();
p1.compare(p2);
return 0;
int main() {
Person p1, p2;
p1.insert();
cout << endl;
p2.insert();
p1.compare(p2);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment