Re: Member function access
Show a piece of your code here and people will be of help.
Re: Member function access
// .h file
class test1 {
func1();
func2();
}
class test2 {
friend class test1;
funct2();
funct3();
}
// cpp file
test1::func1()
{
funct1() // I want just this but the vc compiler gives error
// it doesn't know funct1()
}
Re: Member function access
The compiler says it doesn't know funct1 because funct1 isn't declared anywhere!
You declare func1 and func2 in test1, and funct2 and funct3 in test2, but no funct1.
If funct1 is supposed to be a member of test2, you must call it on an instance of test2 (unless it is declared 'static'):
class test2 {
friend class test1;
void funct1();
void funct2();
void funct3();
};
test1::func1()
{
test2 anInst; // create an instance of test2
anInst.funct1(); // call the function
}
Incidentally, the class declarations must be terminated with a semi-colon (;) after the curly braces, and so should the call to funct1. The member function declarations should be given return types also.
Dave