Note that there are some explanatory texts on larger screens.

plurals
  1. POvirtual data type/enum
    text
    copied!<p>I want a virtual class like this:</p> <pre><code>class Configuration { public: enum EPromptId; virtual CString getPrompt( EPromptId promptId ) = 0; private: }; </code></pre> <p>So that each derived configuration can have its own set of EPromptIds</p> <pre><code> class Configuration1 : public Configuration { public: enum EPromptId{ epid_HappyBirthday }; CString getPrompt( EPromptId promptId ){ return ""; } private: }; class Configuration2 : public Configuration { public: enum EPromptId{ epid_JummpingJehoshaphat }; CString getPrompt( EPromptId promptId ){ return ""; } private: }; </code></pre> <p>This fails as each class needs to implment a virtual function with a Configuration::EPromptId parameter (not a Configuration1::EPromptId or Configuration2::EPromptId as in this code). </p> <p>Is it possible to get the base class to recognise the parameter type but define the values differently in each derived class (perhaps not using enums, but keeping it strongly typed, i.e. not using an int).</p> <p>EDIT : I want two different configurations for two different 'applications'. The prompts could be held in a db table but each 'application' will have it's own table. A pointer to the base configuration class is contained in a class which interfaces to some hardware (i.e. which does the actual displaying). The hardware is an io device that can be used to request and receive user input. When the hardware class is created it will be passed a pointer to the correct configuration class and so display the right prompts when requested.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload