Possible Duplicate:
accessing static member variables
I have a symbol inst which is an object of class classy. I need to access a static member of this class through the object’s symbol. I have tried inst::staticmember but my g++ says error: ‘inst’ is not a class or namespace.
How can I do this?
You use the dot:
::is only for use with namespaces or classes, as you may have discerned from your compiler error.You can access static member variables two ways: either through
classy::staticmemberwhereclassyis a class, orinst.staticmemberwhereinstis a class instance.