is their a way to call a class function within another class function?
Printable View
is their a way to call a class function within another class function?
A) Why not make the function global?
B) Look up the friend declaration. I think it might help you.
but if its a class function, isnt it already global?
Unless it is static, the only way it can be accessed is if a whateverclass example is declared. Such as:
Code:class a
{public:
void func(){cout<<"a class function";};
};
int main()
{a dog;//has to be declared to access func
dog.func();
return 0;
}
If it's a derived Class, and you'd like to implicitly call the function of one of it's classes, check out the :: Operator
ex.
CLASS_X::DISPLAY();
p.s.
Friend Functions prove that your code isn't logically structured.
However that smiley face got there, it should be a 'D'
::d