hi
is it possible to use the class members( which are declared as public) in the main function????
1 2 3 4 5 6 7 8 9 10 11 12
|
class egg
{
public:
int x;
};
int main()
{
egg someEggObject;
someEggObject.x = 7;
return 0;
}
|
Edit: I note that this is the post that made me 1337. Ph34r m3 5k1ll5 :)
Last edited on
just try,write code
then you can understand
You can do this but your O-O prof will tell you off !
Object orientation is about designing interfaces, the user of the class shouldn't need to know
what is going on inside.
Also, you may want to change the mechanism in future, maybe x will become a calculated value instead of an
instance variable.
OK, get, set methods are tiresome to write.
If you use inline functions for your get/set methods then the speed is the same as direct access.