Can someone tell me what i did wrong with this code:
#include
using namespace std;
//Represent a person
//1. Name
//2. Age
//3. Gender
struct Person{
string name;
int age;
string gender;
};
struct Marriage{
Person personA;
Person personB;
int ageOfMarrige;
int numberOfPeopleAtWedding;
};
void printPersonInfo(Person p) {
cout << "The name of the person is "<<p.name<<endl;
cout << "The age of the person is "<<p.age<<endl;
cout << "The gender of the person is "<<p.gender<<endl;
}
void printMarriageInfo(Marriage m){
cout << m.personA.name << " married "<< m.personB.name <<endl;
cout << " They have been married for "<< m.ageOfMarrige << " Number of years "<<endl;
cout << m.numberOfPeopleAtWedding << " People visited thier wedding "<<endl;
}
int main()
{
Person david = {"David", 21, "Male"};
Person clint = {"Clint", 31, "Male"};
Person sara = {"Sara", 29, "Female"};
Marriage marriage = {ivan, sara, 20, 200};
printMarriageInfo(marriage);
return 0;
}
I followed the video on Nested Struct, but my code does not work.
Thanks!