Saturday, 15 March 2014

inheritance - How to forward declare a class that inherits from another class c++? -


I have created a square that has a bunch of heritage classes (parent class) so that I can use polymorphism but the problem is There are two classes that are calling each other.

So I need to forward it to declare them and I can declare a class, but when I declare the class forward, the compiler says that the pointer can not change from one To the other

Is there any way to make a manifesto ahead of the inherited class, so that it tells that it has this message? Ex:

  class size; Square circle: size;  

You do not need to specify the family tree after the name of the class, When to announce further

  class size; Cell division; Square rectangle;  

When you declare classes using heritage, the compiler appreciates the full declaration of basic classes.

One rule of thumb is that the type of declaration of pointers and contexts can be sorted by using forwarding declarations. Any codes accessing elements of a class through pointers or references require a full class announcement.


No comments:

Post a Comment