I'm trying to write my homework without a lot of help from the internet, but I"m having a bit of a hangup on getting my head around a bit of information.
I have been given a class around which I am to program a payroll system and was told to write a get function to access the private data members...
I don't even know what that is or how to even begin to write one, can someone explain this to me?
class MyPrivateIntValue
{
private:
//Nobody outside the class can access this field because it is private!
//How can it then be used by code outside the class? A get accessor, seen below.
int _myPrivateInt;
public:
//Constructor
MyPrivateIntValue() : _myPrivateInt(0)
{ }
//This is the get accessor for the private field above.
int Get_MyPrivateInt() { return _myPrivateInt; }
};
That's how you code a GET accessor, or a GET function, or however you want to name it.