| 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 <><><><><><><><>
.
|
|
|
|
|

|
Related Articles |
|
|