Sunday 15 March 2015

c++ - How to declare a class explicity abstract? -


I am considering the following:

And this is an abstract The class has a pure virtual function in C ++. However, of course it does not mean that I want to create an abstract class which I put in a pure virtual function? Do not I have a situation where I have a solid square which does not provide an implementation for a particular function and therefore forces it to generate derivative classes for execution? Although it can not create the essence of class?

So how can I differentiate between "This is an intangible class" and "a solid square with a pure virtual function"?

A class is clearly summarized when it has one or more pure virtual functions. If you write a base class, in which all functions are implemented, and can be done immediately, but it misses an important task, then this is just a bad design of your classroom. Your base class will not be complete in this case and the pure virtual unconnected function should be added, which makes it an abstract class.

If you have a derived class, which is obtained from an abstract class, and does not apply all the functions from the base class, then this is also the essence in turn. In this case, it is called pure virtual The function will not be required because it is the essence of heritage.

There is no abstract in the keyword C ++ , such as in java indicates that there is a class abstract .

No comments:

Post a Comment