implepmention of pointer member in class

hi all

so iam doing a assignment involving classes and kind of got stuck at the part where i have to implement this line of code:
void setEmployee(string,Person *p)

My classes are as such

class Person{
private:
string name;
string id;

public:
Person();
void setName(string);
void setID(string);
string getName();
string getID();
};


class Employee{
private:
string address;
Person emp;

public:
void setEmployee(string,Person *p);
Person getCustomer();
};

can someone pliz guide on how to define and implement this line:
void setEmployee(string,Person *p)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 */ }
        }
        
        // ...
};
Topic archived. No new replies allowed.