Advertisement

Private/public vars in a class?

Started by July 11, 2003 07:15 AM
12 comments, last by -Egon- 21 years, 7 months ago
Also, if you declare your getter and setter functions as being inline, then there is no loss of speed. Done that way
var_x = MyClass.x; 

takes the same amount of times as
var_x = MyClass.Get_X();   
quote:
Original post by Sneftel
quote:
Original post by Ruudje
well, its a fact that each time you have to call a function, it takes a little time. so retreiving a var using a get-function is in fact a little slower than getting it right away.
Most getter/setter functions can be inlined, and thus have no overhead.




How appropriate. You fight like a cow.


Very true, forgot to mention that.

For those who dont know, this is what he means:

class something
{
private:

int x, y;

public:

int getX( void ) { return x; } // inline function.
etc...
};
Advertisement
I guess someone has to post this, and it can just as well be me: http://www.cuj.com/documents/s=7998/cujcexp1902hyslop/



AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
You''ve convinced me!

---------------------------------------
"It''s only a bit, it can''t hurt you..."
--------------------------------------- "It's only a bit, it can't hurt you..."

This topic is closed to new replies.

Advertisement