c++ - Forward declaration of derived class -


i have code that:

class class1 {     // code here      class2 inverse() {         // code here     } };  class class2 : public class1 {     // code here }; 

and got error class2 unknown in function inverse. can declare class , how?

you can forward declare class2 before class1. , you'll have separate inverse function declaration definition. should define after class2 defined:

class class2; class class1 { // code here  class2 inverse(); };  class class2: public class1 { // code here };  class2 class1::inverse() {     return class2(); } 

but, honestly, bad design.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -