No, but you can achieve the same effect by representing your static data
members as a single object of a class with a default constructor.
[color=blue]
> Can anybody explain me about private and static constructors in c++[/color]
A private constructor is private, only accessible to that class.
There is no such thing as static constructor in C++.
--
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?
plmanikandan@gm ail.com wrote:[color=blue]
> Is static constructor available in C++?[/color]
No, it doesn't make any sense. Do you need your class to be prohibited
from creating more than one time?[color=blue]
> Can anybody explain me about private and static constructors in c++[/color]
Private constructor does exist and it is used to implement, for example,
very popular design pattern "Singleton" .
[color=blue]
> Rgds,
> Mani
>[/color]
Alf P. Steinbach wrote:[color=blue]
> * plmanikandan@gm ail.com:[color=green]
>> [..]
>> Can anybody explain me about private and static constructors in c++[/color]
>
> A private constructor is private, only accessible to that class.
>
> There is no such thing as static constructor in C++.[/color]
Potentially what the OP meant was the "factory method". A static
member that makes an object and returns a pointer (reference) to it.
Private c-tor goes hand in hand with that.
V
--
Please remove capital As from my address when replying by mail
* Victor Bazarov:[color=blue]
> Alf P. Steinbach wrote:[color=green]
>> * plmanikandan@gm ail.com:[color=darkred]
>>> [..]
>>> Can anybody explain me about private and static constructors in c++[/color]
>> A private constructor is private, only accessible to that class.
>>
>> There is no such thing as static constructor in C++.[/color]
>
> Potentially what the OP meant was the "factory method". A static
> member that makes an object and returns a pointer (reference) to it.
> Private c-tor goes hand in hand with that.[/color]
Yes, I think you're right. However, let's point out that "static
constructor" is a relatively standard term in software engineering,
because it does exist in a number of languages. But not in C++.
--
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?
Comment