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
Post a Comment