#include <iostream> #include <string> class A { private: std::string name; public: void getdata( ) { std::cout << "Name: "; std::cin >> name; } void showdata( ) { std::cout << "Your name: " << name << std::endl; } }; class B { private: std::string surname; A a; public: void getdata( ) { a.getdata( ); std::cout << "Surname: "; std::cin >> surname; } void showdata( ) { a.showdata( ); std::cout << "Your surname: " << surname << std::endl; } }; int main( ) { B e; e.getdata( ); e.showdata( ); return 0; }
class A
class B
std::string
main
A* ptr = new B;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)