B
bob holder
Hi folks, I have a question. Can I use a named constructor with templates?
If yes I am not sure the syntax. For example:
template <size_t N> class ABC {
public:
typedef ABC<N> *handle;
static handle create(size_t s) { return new ABC<s>(); }
private:
ABC();
};
main () {
ABC<5>::handle my_abc;
my_abc = ABC<5>.create(5); // compile error this line
}
I need to control the construction process, hence the need to hide the
default ctor.
thanks,
bob
If yes I am not sure the syntax. For example:
template <size_t N> class ABC {
public:
typedef ABC<N> *handle;
static handle create(size_t s) { return new ABC<s>(); }
private:
ABC();
};
main () {
ABC<5>::handle my_abc;
my_abc = ABC<5>.create(5); // compile error this line
}
I need to control the construction process, hence the need to hide the
default ctor.
thanks,
bob