using class variables outside the class.

i'm trying to find the way for how i can do this ? is that am i forgot any simple thing.
I have a class with private member as list and i populated the list in one of member function , i want to use the same from outside the class after populated.

how can i do this using set and get methods..any one explained me
Thanks in advance.
Last edited on
Traditional set and get methods don't model a list class well.

With a list, you add elements (push_front, push_back, insert). That's different from a traditional setter.

With a list, you can also delete an element. No equivalent to the getter/setter model.

Or you can search the list for an item (find), or get the front or back element. Again, no direct mapping to a getter, although you could enhance your getter to take an argument indicating which list element to find.

ohh i think ..i didn't explain you well ..
i want to use the private class member to outside of class ..

that means the class member (list) will be useful in other class member functions.

Last edited on
Then make it public, not private.

The downside of public members is that you break encapsulation.
Want to maintain my list as globally..
Here my list changing in different files diff class . extern is restricted strictly at my end.
i read set and get usage in some where but don't know how i can use in this point any ideas suggestions please..
Topic archived. No new replies allowed.