Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- //birthday class created
- class birthday{
- private:
- int month;
- int day;
- int year;
- public:
- birthday(int m, int d, int y){
- month=m;
- day=d;
- year=y;
- }
- void printDate();
- };
- void birthday :: printDate(){
- cout << month << " " << day << " " << year << endl;
- }
- // people class created
- class people{
- private:
- string name;
- birthday dateOfBirth;
- public:
- people(string x, birthday bo)
- :name(x),dateOfBirth(bo){ // member initialization
- }
- void printInfo();
- };
- void people::printInfo(){
- cout << name << " was born on ";
- dateOfBirth.printDate();
- }
- int main(){
- birthday jon(4, 13, 108);
- people lyanna("jon the stargaryen", jon);
- lyanna.printInfo();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment