Good day guys.
I have the following struct and class,
template <class T>
struct Node
{
T DataMember;
Node* Next;
};
template <class T>
class NCA
{
public:
NCA();
~NCA();
void push(T);
T pop();
void print();
void Clear();
private:
Node<T>* Head;
void* operator new(unsigned int);
};
I would like to instantiate the class with a size
ie. NCA[30] as one would any array
If the compiler were to allow you to use brackets in your object constructor, how would it know whether you were trying to make an
NCA
of size 30 or an array of 30NCA
objects? C++ does not allow you to override the bracket syntax, except as an operator once you already have an object.