C
Chris Croughton
What do people call their factory functions? 'new' is not an option
(yes, it can be overloaded but has to return void*).
The context is:
class MyClass
{
public:
// Factory functions
static MyClass* new(int);
// Produce a copy of the class
virtual MyClass* dup() = 0;
// Access functions
virtual int whatever(int) = 0;
};
To me it makes most sense to say:
MyClass* mp = MyClass::new(1);
but 'new' isn't allowed.
Are there any quasi-standard names for the factory functions? Whatever
the name it shouldn't repeat information which is already known
(MyClass::newMyClass() is silly). The "make a copy" function, dup(),
is reasonably named (OK, I like short names).
I want a word which implies that what is returned is a pointer to a new
version of the class ('make' and 'create' don't imply that to me)...
Chris C
(yes, it can be overloaded but has to return void*).
The context is:
class MyClass
{
public:
// Factory functions
static MyClass* new(int);
// Produce a copy of the class
virtual MyClass* dup() = 0;
// Access functions
virtual int whatever(int) = 0;
};
To me it makes most sense to say:
MyClass* mp = MyClass::new(1);
but 'new' isn't allowed.
Are there any quasi-standard names for the factory functions? Whatever
the name it shouldn't repeat information which is already known
(MyClass::newMyClass() is silly). The "make a copy" function, dup(),
is reasonably named (OK, I like short names).
I want a word which implies that what is returned is a pointer to a new
version of the class ('make' and 'create' don't imply that to me)...
Chris C