c++ - Need objects of inheriting classes to be visible before classes are defined -


usually declare , define base class , same inheriting class before declaring objects of inheriting class. unfortunately for visibility reasons need declare objects before inheriting class defines (although after base class defined).

i though make forward declaration inheriting class if this:

class baseclass {     //content };  class inheritingclass; 

it not recognise inheriting if this.

class baseclass {     //content };  class inheritingclass: public baseclass; 

the compiler expects me finish definition. possible make situation describing work?

i tried in compiler. can declare class identical base, , use type checking, , derive when define it. presumably subcategory of base class looking for. however, won't exact type. if you're not looking partition hierarchy, still think base class should using, since looking for.

class base {int unused;}; class base_specific : public base {};  class actual : public base_specific { public:     actual (int i) : m(i) {}     int m; };  int main(){     actual x(4); } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -