#include #include using namespace std; struct PersonData{ string name="other name"; int age = 10; }; class PersonT { public: PersonT(string n="none", int a=-1) : name(n), age(a) { cout << "in the default constructor for PersonT" << endl; } PersonT(int a ): name("none"), age(a) { cout << "in the age constructor for PersonT" << endl; } PersonT(double a): PersonT(static_cast(a)) { cout << "in the delegated constructor for PersonT" << endl; cout << "\tparameter: " << a << " age: " << age << endl; } PersonT(const PersonData & p): name(p.name), age(p.age) { cout << "in the struct constructor for PersonT" << endl; } string Name(void) const { return name; } int Age(void) const { return age; } private: string name; int age; }; ostream & operator<<(ostream & s, const PersonT & p) { s << p.Name() << ":" << p.Age(); return s; } int main() { PersonData pd; PersonT a; cout << a << endl << endl; PersonT b("hello", 1); cout << b << endl << endl; PersonT c(4); cout << c << endl << endl; PersonT d(b); PersonT x = b; cout << d << endl << endl; PersonT e(pd); cout << e << endl << endl; PersonT f("goodDay"); cout << f << endl << endl; PersonT g={"ilsit",99}; cout << g << endl << endl; PersonT h(3.14); cout << h << endl << endl; return 0; }