From: Bo Persson on
Lorry Astra wrote:
> Thanks.
>
> I've learned all of the answers, I think maybe I misunderstand the
> concept of pure virtual function and abstract class when some
> classed inheritate from it. What I understand is: If a new
> class(common class, not abstract one) inheritates from an abstract
> class, it must define all of the pure virtual functions, if not,
> then this new class has an error and we can justify this error not
> until we define an object of this new class.
>
> And what I can get the view of c++ compiler is : if a new class
> inheritates from an abstract class, new class doesn't need to
> define all of the pure virtual functions, that's no problem, but
> you can't define an object of this new class, if you define one,
> you are wrong.
> Is that right?

Yes, the derived class is still an abstract class. You can derive
further from this, perhaps several classes, and defined the remaining
functions there.

Like Arnaud said in another post, C++ just has classes. It is our
choice to use them as interfaces or abstract base classes. Nothing in
the languages stops us from mixing the concepts - it is up to us, the
programmers, to choose how to use it.


Bo Persson


From: Ben Voigt [C++ MVP] on
Lorry Astra wrote:
> Thanks.
>
> I've learned all of the answers, I think maybe I misunderstand the
> concept of pure virtual function and abstract class when some
> classed inheritate from it. What I understand is: If a new
> class(common class, not abstract one) inheritates from an abstract
> class, it must define all of the pure virtual functions, if not, then

But you derived a new abstract class, not concrete (which you called "common
class"), so none of the rest of your reasoning applies.

> this new class has an error and we can justify this error not until
> we define an object of this new class.
>
> And what I can get the view of c++ compiler is : if a new class
> inheritates from an abstract class, new class doesn't need to define
> all of the pure virtual functions, that's no problem, but you can't
> define an object of this new class, if you define one, you are wrong.
> Is that right?