【发布时间】:2025-12-10 06:50:01
【问题描述】:
我在 ADialog 类中有一个函数,它有一个用户输入 x11,我想在 BDoc 类中调用一个函数。怎么做?
.h file
#ifndef A_DIALOG_H
#define A_DIALOG_H
class ADialog : public wxDialog
{
public:
ADialog(wxWindow* parent, wxWindowID id, int click);
wxTextCtrl *d_x1;
void setAData();
};
#endif
.cpp 文件的一部分
void ADialog::setAData()
{
double x11;
d_x1->GetValue().ToDouble(&x11);
}
.cpp 文件的一部分
void BDoc::ATCut()
{
//(get the value of x11 that user inputs in this part)
}
【问题讨论】:
-
我在
ADialog中没有看到任何方法。 -
setAData() 不是成员函数吗?
-
在类声明中没有这样声明。我不知道是
public还是private。是static还是不是?你能发布完整的课程吗? -
哦好的抱歉,它是公开的,我会编辑它
-
因为不是
static,所以需要BDoc中的ADialog实例才能从该方法中获取结果。