.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Programming (http://forums.bots-united.com/forumdisplay.php?f=25)
-   -   C++ Inheriting problem (http://forums.bots-united.com/showthread.php?t=5136)

Rick 10-04-2006 21:47

C++ Inheriting problem
 
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 :ph34r: ... 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]


All times are GMT +2. The time now is 11:11.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.