| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"MJ" |
| Date: |
01 Aug 2005 12:53:47 AM |
| Object: |
ctor as protected |
Hi
can I define constructor as protected??
if yes than what are the implications and what is the diff bet defining
the ctor as
protected and public
Mayur
.
|
|
| User: "sachin" |
|
| Title: Re: ctor as protected |
01 Aug 2005 02:05:03 AM |
|
|
Defining c'tor protected or private means no body can instantiate it
except the class derived from it.
public c'tor class can be instantiated from any where in your code
sachin
.
|
|
|
| User: "BigBrian" |
|
| Title: Re: ctor as protected |
01 Aug 2005 07:37:03 AM |
|
|
Defining c'tor protected or private means no body can instantiate it
except the class derived from it.
Or static members of the class, or friends of the class.
-Brian
.
|
|
|
|
| User: "" |
|
| Title: Re: ctor as protected |
01 Aug 2005 03:15:40 AM |
|
|
Public declaration of ctor allows all fuctions to acces it.If declared
private or protected it is accessible only from the class itself or
inherited classes respectively.
Private or protected calss constructors are rarely used.
one example is the implementation of singleton design patterns.
Gevadas
.
|
|
|
|
| User: "" |
|
| Title: Re: ctor as protected |
01 Aug 2005 03:14:13 AM |
|
|
see Singleton and Factory in <<Desing patterns>> and you will
understand when need to do that
.
|
|
|
|
|

|
Related Articles |
|
|