can someone help me with classes

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?
Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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.
Topic archived. No new replies allowed.