Several questions from there.
The first and most important is , how do I factor from here?
Can I do a class
1 2 3 4 5 6 7 8
class MyInt: public Type<int>{
public:
MyInt();//should I add a new constructor? Should Type and ~Type be void?
specific methods();
private:
new attributes and private methods ...
}
If not, how can I do both genericity and add some specific function inside a sub class?
If yes, if I increase MyInt::count would it increase for all instances of Type?
Thanks.
count is only static for each T
so type<double> d and type<int> i has 2 static variable count instances. If you then say type<int> i2, then i and i2 share the static int count variable, and d (double) one is unaffected by changes to the int one.
I see no reason for empty constructors or destructors in either class here. But that depends on what all the other stuff in your classes really is, as these are empty examples.
Ok thanks both of you. It answers my questions.
We were told to always put a constructor and a destructor, but actually I was wondering if I was not creating too many objects if I put two of them, one in the parent class and the other in the child.