.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Programming
General Programming Help others and get yourself helped here!

Reply
 
Thread Tools
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 23:03..
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com