Why C++ has given pure virtual methods?

A

a2z

From design point of view, I have other work around to get following
behavior of pure virtual methods:

1. To make a class abstract I can make constructor/destructor private.

What is the thing I'm missing because of which C++ has supported
pure virtual mechanism?
Kindly let me know?

~Thanks,
Ramesh
 
J

Juha Nieminen

a2z said:
From design point of view, I have other work around to get following
behavior of pure virtual methods:

1. To make a class abstract I can make constructor/destructor private.

Don't you mean protected?

You can make a whole class abstract that way, but you can't make an
individual member function abstract that way.

In some cases it makes sense design-wise that the inherited class must
implement a given virtual function because it has no sensible default
implementation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top