class A {
public:
void memberofa();
}
b级:
class B {
public:
void memberofb();
}
现在我需要从memberofb内部调用memberofa。 任何建议和语法都会有所帮助
答案 0 :(得分:0)
这样的东西?
class A {
public:
A() {};
void memberofa()
{
//you cant make object of B here because compiler doesn't see B yet
//if you do want to make Object of B here, define this function somewhere
//after definition of B class
printf("printing from member of A\n");
};
};
class B {
public:
B() {};
void memberofb()
{
printf("printing from member of B\n");
A objA;
objA.memberofa();
};
};
int main()
{
A a;
B b;
b.memberofb();
return 0;
}
答案 1 :(得分:0)