【发布时间】:2011-04-02 02:30:57
【问题描述】:
Z.h
struct Z {
Z();
~Z();
void DoSomethingNasty();
}
X.h
struct X {
X();
~X();
void FunctionThatCallsNastyFunctions();
}
MainClass.h
#include "Z.h"
#include "X.h"
struct MainClass {
MainClass();
~MainClass();
private:
Z _z;
X _x;
}
X.cpp
X::FunctionThatCallsNastyFunctions() {
//How can I do this? The compiler gives me error.
_z.DoSomethingNasty();
}
我应该怎么做才能从_z 对象调用DoSomethingNasty() 函数?
【问题讨论】:
-
分享错误信息会有所帮助。
-
您的代码有错字 _z.DoeSomethingNasty(); _z.DoSomethingNasty();给出错误
-
我真的怀疑你需要那些析构函数。 (例如,构造函数。)
标签: c++ class scope friend access-control