Reputation: 2699
I am writing a template Array class. I can use it to declare things like this,
Array<int> oneDimenional(5);
But not this...
Array<Array<Array<Array<Array<Array<Array< int >>>>>>> Craziness(1000);
My class starts out like this,
template <typename T>
class Array{
private:
int len;
T *arr;
public:
Array() {
int len = 0;
}
Array(int size) {
arr = new T[size];
len = size;
}
~Array() {
delete[] arr;
}
//...
};
I'm guessing I need to change my constructor?
Upvotes: 0
Views: 58
Reputation: 4245
Array<Array<int> > arr(10);
leave space between >>. since this is considered as >> right shift. and thats why the error It 'll be shown in compiler itself and its a common mistake.
error: '>>' should be '> >' within a nested template argument list
so your code should be
Array<Array<Array<Array<Array<Array<Array< int > > > > > > > Craziness(1000);
Upvotes: 2