Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Abstract class with no abstract functions

Reply
Thread Tools

Abstract class with no abstract functions

 
 
Uzytkownik
Guest
Posts: n/a
 
      04-03-2005
I've class C1, C2 and C3. C1 should be abstract, and all functions
should be defined like normal, no-virtual functions. It don't have to
have constructor.
C2 is C1 with constructor.
C3 is C2 with constructor(both take long time and one exclude second)
and additional functions and members.
Haw do it, when I've not pure-virtual function?
I use g++.
Regards.
--
Linux user: #376500 (see http://counter.li.org/)
 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      04-03-2005
* Uzytkownik:
> I've class C1, C2 and C3. C1 should be abstract, and all functions
> should be defined like normal, no-virtual functions. It don't have to
> have constructor.
> C2 is C1 with constructor.
> C3 is C2 with constructor(both take long time and one exclude second)
> and additional functions and members.
> Haw do it, when I've not pure-virtual function?


class C1{ public: virtual ~C1() = 0 }; inline C1::~C1(){}

However, there's something in that design description that sounds
very bad.

Perhaps you're using constructors where ordinary functions would
be more appropriate?

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
 
 
 
Malte Starostik
Guest
Posts: n/a
 
      04-03-2005
Uzytkownik schrieb:
> I've class C1, C2 and C3. C1 should be abstract, and all functions
> should be defined like normal, no-virtual functions. It don't have to
> have constructor.
> C2 is C1 with constructor.
> C3 is C2 with constructor(both take long time and one exclude second)
> and additional functions and members.
> Haw do it, when I've not pure-virtual function?
> I use g++.
> Regards.


What exactly do you want to achieve? If all you want is to prevent
instantiation of C1, add a protected empty inline default ctor. If
that's totally off your problem, it might help if you provided some code
to clarify what you want to do and where exactly your prolem is.

Cheers,
Malte
 
Reply With Quote
 
Uzytkownik
Guest
Posts: n/a
 
      04-03-2005
Alf P. Steinbach wrote:
> * Uzytkownik:
>
>>I've class C1, C2 and C3. C1 should be abstract, and all functions
>>should be defined like normal, no-virtual functions. It don't have to
>>have constructor.
>>C2 is C1 with constructor.
>>C3 is C2 with constructor(both take long time and one exclude second)
>>and additional functions and members.
>>Haw do it, when I've not pure-virtual function?

>
>
> class C1{ public: virtual ~C1() = 0 }; inline C1::~C1(){}
>


It's work.
Thanks.

--
Linux user: #376500 (see http://counter.li.org/)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the difference between abstract class and pure abstract class? skishorev@yahoo.co.in C++ 4 05-17-2006 08:07 AM
Re: Abstract Methods & Abstract Class Gerald Klix Python 1 10-20-2005 02:44 PM
Abstract Methods & Abstract Class Iyer, Prasad C Python 0 10-20-2005 06:35 AM
About abstract class and abstract method Sameer Java 4 08-31-2005 12:59 AM
Deriving abstract class from non-abstract class Matthias Kaeppler Java 1 05-22-2005 01:28 PM



Advertisments