Hi All,
If you have the following class:
class foo
{
private:
int offset;
public:
void SetOffset(int InOffset);
};
foo::SetOffset(int InOffset)
{
offset = InOffset;
}
foo::DoSomething(int offset, int......)
{
// I can set offset two ways
SetOffset(InOffset); //1
offset = inOffset; //2
}
The question, within the class, should I call SetOffset, or just set
the private member. I know calling SetOffset causes an overhead (
function call), but you can say that if we make the SetOffset inline,
that will eliminate the overhead of calling function.
I always set the class memeber directly without the need to call the
function "SetOffset", but I ran into code that calls the function
instead of just changing the value of the class attributes. Any
suggestions why somebody would do that?
Question 2)
Have you seen something like this in the class declaration? why would
you do so?
foo(foo * pfoo); // foo is the class name
Thanks for the feedback.