12345678910111213141516171819202122
class Employee { private: std::string address; Person emp; public: // note: this is not exception-safe // (favour using a constructor to initialise the object) void setEmployee( std::string addr, const Person* p ) { if( p != nullptr ) { address = addr ; // or swap address, addr emp = *p ; } else { /* error: invalid argument */ } } // ... };