【发布时间】:2014-07-29 04:16:22
【问题描述】:
我试图通过函数的地址调用另一个类的函数。 我有两个课程 CA 和 CB
CA 有类似的方法
void CA :: CreateList()
{
m_pWindow = DEBUG_NEW CA;
if(! m_pWindow ->Create(_T("CListsdbb"),NULL,WS_CHILD|WS_VISIBLE|LVS_ICON|LVS_SINGLESEL , CRect(0, 0, 0, 0), this, NULL))
{
TRACE0("Falied to create list window");
return;
}
}
m_pWindow是CWnd*类型CA的属性。
我还有另一个班级 CB。我试图在其中调用此函数 无效的创建列表();
喜欢
void CB :: OnBtn(void)
{
&CA::CreateList;
MessageBox(_T("Hello world"), _T("Information"), MB_OK);
}
但是函数没有调用。 CA 是集装箱船 CB 的所有者。
请任何人帮助我解决这个问题。
【问题讨论】:
-
试试
CA::CreateList(); -
我试过了但没有给出错误 non-static member reference must be relative to an object。而 CreateList() 是公开的:
-
如果 CA 是 CB 的所有者,请尝试
((CA*)GetParent)->CreateList();。 -
请澄清您所说的“CA 是集装箱船 CB 的所有者”是什么意思。
-
CA 是集装箱船中 CB 的所有者,CA 是 CB 的父代