Basically I'm pretty new to C++, I'm trying to implement the getting and setter function within a class data member using a struct, I got no idea where to start. I've looked around the internet but there's nothing that I can see. Here is the code: (Can you keep any explanations extremely simple)
class CPayRoll
{
private:
SEmployee* mp;
public:
CPayRoll( string name, int id );
~CPayRoll();
void SetDetails( string name, int id );
void GetDetails( string& name, int& id );
};
CPayRoll::CPayRoll( string name, int id )
{
mp = new SEmployee;
mp->name = name;
mp->id = id;
}
CPayRoll::~CPayRoll()
{
delete (mp);
}
void SetDetails( string name, int id )
{
}
void GetDetails( string& name, int& id )
{
}
int main()
{
CPayRoll* Olly = new CPayRoll("Olly",100);
Well how do I implement the Getter and Setter using a struct?
I've tried cout << = *mp->name;
But I just get lots of errors :-/
Your question on the surface really makes little sense. Typically a Set method just takes a value as an argument and assigns it to a member of a class or struct. A Get method just returns a member of a class or struct.
So, what are you really trying to do. Explain what you want to do, not how you want to do it.
Bookmarks