MFC一个类如何调用其他类中的成员函数?

我在CRubberbandView这个类中写好了一个成员函数void bresenham(double,double,double,double),想在CDialog1类中OnOK()的调用bresenham()这个函数,使得点击后运行CRubberbandView这个类中的bresenham()函数,应该怎么做

海绵宝宝撒
浏览 920回答 4
4回答

梦里花落0921

在CDialog1中包含CRubberbandView的头文件在CDialog1的ONOK()函数中定义一个CRubberbandView的对象rb调用函数 rb. bresenham试下可以不

慕尼黑5688855

用指针://B.hclass B{public:Fun();};CB * GetB(); //全局函数//B.CPPCB g_B;CB * GetB(){return &g_B;}//A.cpp#include "B.h"GetB().Fun(); //可以这样调用B中的成员函数Fun()

繁星淼淼

想办法获得CRubberbandView的一个指针,用指针调用那个函数如果你那个View已经注册过,且处于active 状态,可用//#include "mainframe.h"//#inlcude "ruberandview.h"CMainFrame *pMain=(CMainFrame *)AfxGetApp()-> m_pMainWnd;CRubberbandView *pView=(CRubberbandView *)pMain-> GetActiveView();pView->bresenham();

有只小跳蛙

//#include "mainframe.h"//#inlcude "ruberandview.h"CMainFrame *pMain=(CMainFrame *)AfxGetApp()-> m_pMainWnd;CRubberbandView *pView=(CRubberbandView *)pMain-> GetActiveView();pView->bresenham();
打开App,查看更多内容
随时随地看视频慕课网APP