#67203 - LOst? - Mon Jan 16, 2006 5:21 am
Okay, I need to program C++ classes for the moment. I want one class for the level, one class for the level meta, and one class for the player.
Now the player needs to know where in the level he is at, and the level needs to access the level meta to draw the level.
If I put all data in private for each classes, I need to do these methods in public:
Imagine me doing the heavy calculations like this:
If you know how C++ compile these in machine code like I know, then you see my problem. (hint = stack usage high! Slow calculations! Stupid!)
I don't like this. I want to access the x variable directly from another class, but I still want it to be private to the rest of the program.
Is there any solution in C++, that still will be considered true OOP?
And no, I won't put everything in Public. Then I will just skip OOP and do regular C.
_________________
Exceptions are fun
Now the player needs to know where in the level he is at, and the level needs to access the level meta to draw the level.
If I put all data in private for each classes, I need to do these methods in public:
Code: |
int ReturnLevelX () { return x; } |
Imagine me doing the heavy calculations like this:
Code: |
offset = ReturnLevelX () + ReturnLevelY () * ReturnLevelWidth (); |
If you know how C++ compile these in machine code like I know, then you see my problem. (hint = stack usage high! Slow calculations! Stupid!)
I don't like this. I want to access the x variable directly from another class, but I still want it to be private to the rest of the program.
Is there any solution in C++, that still will be considered true OOP?
And no, I won't put everything in Public. Then I will just skip OOP and do regular C.
_________________
Exceptions are fun