[英]how do I call the function from the upper class? the class is not inherited
class a{
private:
class b* b = new b;
int getSomeWhatValue(){
}
};
class b{
private:
void bFunc(){
//I want to call an getsomewhatvalue() here
}
};
I made the code really simply.我把代码写得很简单。 How do I call an a's function at b?
如何在 b 调用 a 的 function? I tried to use
this
pointer, but didn't work:(我试图使用
this
指针,但没有用:(
Your scenario will cause a cyclic calling (ie never ending loop of A creating an instance of B which in tern creates an instance of A and the loop continues), so its not permissible.您的场景将导致循环调用(即 A 的永无止境的循环创建 B 的实例,该实例在 tern 创建 A 的实例并且循环继续),因此它是不允许的。
You have two options:你有两个选择:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.