比如一个
class class1 : public CDialog
{};
我还想让class1继承我自己写的一个类class2。能实现吗?主要因为class2里有个虚函数,在class1里要重写的,以便class2调用,否则就要通过函数传递一个class1类里的一个回调函数的指针给class2,那样的话,回调函数只能是static或全局函数,就不能访问class1的成员了,怎么办?

解决方案 »

  1.   


    class CTCPServerDlg : public CDialog, public CMsgReceiver
    {
    // Construction
    public:
    CTCPServerDlg(CWnd* pParent = NULL); // standard constructor// Dialog Data
    //{{AFX_DATA(CTCPServerDlg)
    enum { IDD = IDD_TCPSERVER_DIALOG };
    CEdit mEditHostName;
    CEdit mEditHostIP;
    int mHostPort;
    //}}AFX_DATA // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CTCPServerDlg)
    protected:
    virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
    //}}AFX_VIRTUAL// Implementation
    protected:
    HICON m_hIcon; CTCPListener mListener;
    CSocketSender mNetSender; virtual bool ReceiveMessage(MessageT inMessage, void * ioParam, 
    void * ioParam2); // Generated message map functions
    //{{AFX_MSG(CTCPServerDlg)
    virtual BOOL OnInitDialog();
    afx_msg void OnPaint();
    afx_msg HCURSOR OnQueryDragIcon();
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };
      

  2.   

    以上引用自<DIRECTSHOW实务精选>