-
help in classes
Hi.
I am stuck in the following problem and I am hoping that if anyone can help me in this.
So imagine a class..
Code:
Class myClass{
func1(params );
func2(params);
private:
---state vars--
}
Now.. lets say in definitations, I want to use the func2 definition in func1..
how do i use it?
Code:
myClass::func1()
{
//needs to call func2() here..
}
It would nice if anyone can guide me in this..
Thanks a lot for help and suggestion.
best regards
-
Since both functions are part of the same class you would call it just like a global function.
Code:
myClass::func1()
{
funct2(); // call func2() here..
}
Jim
-
In the position you've written it..The ""---state vars--"" would already be private...
and in Code:
//needs to call func2() here..
I've recently heard that
Code:
this->func2(..params..);
is a better practice than;
Is it true...if yes..why?
-
In my opinion I don't think it is a better practice, to me it just adds clutter to the function.
Jim