Wednesday, 7 August 2013

Benefits of Static Functions for Class Constructions

Benefits of Static Functions for Class Constructions

I have seen code like this, so I'm trying to find the reason.
What's the main reason for having static functions that act as
constructors, instead of having actual constructors?
I mean something like:
class MyClass
{
public:
static MyClass CreateFrom( bar );
static MyClass CreateFrom( foo );
...
}
instead of:
class MyClass
{
public:
MyClass( bar );
MyClass( foo );
...
}

No comments:

Post a Comment