Restrict the class the inheritance.



 DEVELOP > c-Plus-Plus > Restrict the class the inheritance.

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Neha"
Date: 22 Nov 2003 02:41:55 AM
Object: Restrict the class the inheritance.
Hi,
I have a class, i don't want any other class to be derived from that.
How can i do this?
Regards
.

User: "=?iso-8859-1?Q?Juli=E1n?= Albo"

Title: Re: Restrict the class the inheritance. 22 Nov 2003 10:39:55 AM
Neha escribi=F3:

I have a class, i don't want any other class to be derived from that.

class FinalizeMyClass {
friend class MyClass;
FinalizeMyClass (); // Private constructor
};
class MyClass : virtual private FinalizeMyClass {
};
That way you can't instantiate any class derived from MyClass.
Regards.
.

User: "Rolf Magnus"

Title: Re: Restrict the class the inheritance. 22 Nov 2003 06:17:54 AM
Neha wrote:

Hi,

I have a class, i don't want any other class to be derived from that.

How can i do this?

Just don't derive from it then.
.
User: "helge"

Title: Re: Restrict the class the inheritance. 22 Nov 2003 10:26:10 AM
Rolf Magnus wrote:

Neha wrote:


Hi,

I have a class, i don't want any other class to be derived from that.

How can i do this?



Just don't derive from it then.

no - I do not think that you can do it in C++.
"I have a class, i don't want any other class to be derived from that"
- it is a JAVA thing:
final public class A {
}
can not be "extended"/inherited from.
_______________________________________________________________________________
Posted Via Uncensored-News.Com - Accounts Starting At $6.95 - http://www.uncensored-news.com
<><><><><><><> The Worlds Uncensored News Source <><><><><><><><>

.



  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER