Abstract class as interface
-
Hi! I am writing a custom window control in MFC: a tab control.
CWnd
A
|
|
MyTabclass MyTab : protected CWnd {
public:
void add(const CString& title, CDialog* dlg);
...
protected:
...
private:
...
};Everything goes well. Now I want to seperate interfaces from implementation theorically:
CWnd ITab (abstract class as interface)
A A
| /
| /
MyTabclass ITab {
public:
virtual void add(const CString& title, CDialog* dlg)=0;
};class MyTab : public ITab, protected CWnd {
public:
virtual void add(const CString& title, CDialog* dlg);
...
protected:
...
private:
...
};This time, the problem exist: there is no HWND attached. Does anyone know how to solve this? Or is there an alternative design? Any reply would be appreciated. sovann. Why waste time learning while ignorence is instantaneous ? [Hobbes]
-
Hi! I am writing a custom window control in MFC: a tab control.
CWnd
A
|
|
MyTabclass MyTab : protected CWnd {
public:
void add(const CString& title, CDialog* dlg);
...
protected:
...
private:
...
};Everything goes well. Now I want to seperate interfaces from implementation theorically:
CWnd ITab (abstract class as interface)
A A
| /
| /
MyTabclass ITab {
public:
virtual void add(const CString& title, CDialog* dlg)=0;
};class MyTab : public ITab, protected CWnd {
public:
virtual void add(const CString& title, CDialog* dlg);
...
protected:
...
private:
...
};This time, the problem exist: there is no HWND attached. Does anyone know how to solve this? Or is there an alternative design? Any reply would be appreciated. sovann. Why waste time learning while ignorence is instantaneous ? [Hobbes]
Sovann wrote: This time, the problem exist: there is no HWND attached. I have not understood what it means (hwnd of what???), but I want to give you small advice: mfc classes must be first at deriving order (MSDN says that). Swap 'public ITab' and 'protected CWnd', otherwise you will have a problems