我想在类的结构和访问函数成员中定义类的对象。是否有可能实现这一目标?结构中的类
使用下面的代码,我得到ps_test->AttachToInput(2145);
的分段错误。我想不通的原因,一切看起来正确的对我说:
class test
{
public:
test();
virtual ~test();
int init_app(int argc, char* argv[]);
virtual void AttachToInput(int TypeNumber, int DeviceNo=0);
}
struct capture
{
test h_app;
gint port;
};
main()
{
struct capture h_cap;
test *ps_test = &h_cap.h_app;
ps_test->AttachToInput(2145);
}
您遇到过什么问题? –
您不能调用'AttachToInput',因为它是受保护的,所以只有派生类可以使用它。 (它的工作方式与Java中的不同。)这是你的问题吗? –
“我有一个独特的”!? –