Connecting Tech Pros Worldwide Help | Site Map

Abstract class with no abstract functions

Uzytkownik
Guest
 
Posts: n/a
#1: Jul 23 '05
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/)
Alf P. Steinbach
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Abstract class with no abstract functions


* Uzytkownik:[color=blue]
> 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?[/color]

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?
Malte Starostik
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Abstract class with no abstract functions


Uzytkownik schrieb:[color=blue]
> 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.[/color]

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
Uzytkownik
Guest
 
Posts: n/a
#4: Jul 23 '05

re: Abstract class with no abstract functions


Alf P. Steinbach wrote:[color=blue]
> * Uzytkownik:
>[color=green]
>>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?[/color]
>
>
> class C1{ public: virtual ~C1() = 0 }; inline C1::~C1(){}
>[/color]

It's work.
Thanks.

--
Linux user: #376500 (see http://counter.li.org/)
Closed Thread