I have a template to create instance of various objects. The template has a static array of class declaration which is supposed to create an array of class type being passed during its creation.
In below example myclass is the static array of class object with size 200 - which can be bigger also. Note that the template can be instantiated with different objects - so the type of array will also be changed accordingly:
#include <iostream>
template <class object>
class A : public object
{
public:
void* operator new(std::size_t sz);
void operator delete(void* ptr);
static object myclass[200];
....
};
template <class object>
A<object> myclass[200];
How can initialise the static array during declaration itself - do I need it to do it new / delete overloaded operator? How will the object construction & destruction occur them if some object references the array as they are static before template instantiation?
Aucun commentaire:
Enregistrer un commentaire