Untitled
unknown
plain_text
3 years ago
1.9 kB
2
Indexable
#include <iostream> class Birthday{ int d; int m; int y; //Constructor public: Birthday(){d = 0; m = 0; y=0;}; Birthday(const int &day, const int &month, const int &year){ d = day; m = month; y = year; } //getter int getDay(){return d;} int getMonth(){return m;} int getYear(){return y;} //copy date void Copy(const Birthday &other){ d = other.d; m = other.m; y = other.y; } }; class student{ std::string name; int age; Birthday date(); std::string Hometown; std::string Class; std::string level_of_studying; //Construtor public: student(){name = "No Information"; age = 0; Hometown = "No Information"; Class = "No Information"; level_of_studying = "No Information";}; student(const std::string &_name, const int &_age, const Birthday &s_date, const std::string &_Hometown, const std::string &_Class, const std::string &_level_of_studying ){ name = _name; age = _age; date.Copy(_date); Hometown = _Hometown; Class = _Class; level_of_studying = _level_of_studying; } //Print out screen student"s information Print(){ std::cout<<"Student:" <<std::endl; std::cout<<"Name: " <<name <<std::endl; std::cout<<"Age: " <<age <<std::endl; std::cout<<"Birthday: " <<date.getDay() <<"/" <<date.getMonth() <<"/" <<date.getYear() <<std::endl; std::cout<<"Hometown: " <<Hometown <<std::endl; std::cout<<"Class: " <<Class <<std::endl; std::cout<<"Level_of_studying: " <<level_of_studying <<std::endl <<std::endl; } }; int main() { Birthday person_Birthday(17,7,2003); student person("Ha Son Tung", 18,person_Birthday,"Tuyen Quang","First year","Excellent"); person.Print(); return 0; }
Editor is loading...