View Single Post
C++ Inheriting problem
Old
  (#1)
Rick
Council Member
 
Rick's Avatar
 
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default C++ Inheriting problem - 10-04-2006

I got problems with some classes in C++. Here is the situation:

in main.h
Code:
class CMain
{
protected:
    virtual char *GetPassword(void *p) = 0;
    virtual bool YesNoBox(const char *str, ...) = 0;
    virtual int ChoiceBox(const char *button1, const char *button2, const char *button3,
                          const char *title, ...) = 0;
public:
    virtual ~CMain(void) { };
    
    virtual void Init(int argc, char *argv[]) { };
};
    
class CBaseInstall: public CMain
{
    // Some functions that use functions from CMain
};
in fltk.h:
Code:
class CFLTKBase: public CMain
{
    Fl_Window *m_pAboutWindow;
    Fl_Return_Button *m_pAboutOKButton;
    
protected:
    Fl_Window *m_pMainWindow;
    Fl_Button *m_pAboutButton;
    
    char *GetPassword(void *p) { };
    virtual bool YesNoBox(const char *str, ...) { };
    virtual int ChoiceBox(const char *button1, const char *button2, const char *button3,
                          const char *title, ...) { };
    // ....    
};

class CInstaller: public CFLTKBase, public CBaseInstall
{
    Fl_Wizard *m_pWizard;
    std::list<CBaseScreen *> m_ScreenList;
    
protected:
    virtual void AddStatusText(const std::string) = 0;
    virtual void SetProgress(int percent) = 0;
    // ...    
};
Problem: I can't use CInstaller since the compiler complains about that GetPassword(), YesNoBox() and ChoiceBox() aren't defined.
What I want: I want that the compiler uses those functions from CFLTKBase.

The only way I know is to define those functions in CInstaller anyway and point them to the ones from CFLTKBase, but that feels a bit hakish
So if anyone knows a better way...


[EDIT]
Yay fixed it ... guess this thread was a bit useless.

Solution: change 'public CMain' to 'virtual public CMain' for both classes so that they use the same CMain(atleast thats what I understand from it).
[/EDIT]

Last edited by Rick; 10-04-2006 at 22:03..
  
Reply With Quote