Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C - C++ Learning > Re: Abstract cl...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 4198 of 4302
Post > Topic >>

Re: Abstract class without virtual functions?

by Bart van Ingen Schenau <bart@[EMAIL PROTECTED] > Jul 10, 2008 at 05:53 PM

Hansen wrote:

> Hi Group,
> 
> Is it possible to make an abstract class without having any virtual
> functions?

Not in the sense that the C++ standard uses the term 'abstract class'.
In that sense, at least one member function must be declared as pure
virtual for a class to be abstract. This member function could be the
destructor.

> I have a fully functional class, but the plan is that one must derive
> from it in order to make more specialized cl*****.

I don't see how this design is going to work.
If the base class does not have any virtual functions, a derived class
will not be able to override/enhance the base class behaviour, so what
advantage does it give you to derive from this base class?

What you also have to watch out for, is that you can't do
  Base* b = new Derived;
  delete b;
unless Base has a virtual destructor.

> 
> /Hansen

Bart v Ingen Schenau
-- 
a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq
c.l.c FAQ: http://c-faq.com/
c.l.c++ FAQ: http://www.para****ft.com/c++-faq-lite/
 




 3 Posts in Topic:
Abstract class without virtual functions?
"Hansen" <bl  2008-07-10 14:16:54 
Re: Abstract class without virtual functions?
"Daniel T." <  2008-07-10 05:34:49 
Re: Abstract class without virtual functions?
Bart van Ingen Schenau &l  2008-07-10 17:53:09 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 13 4:28:04 CDT 2008.