#include<string>
using namespace System;
using namespace std;
struct Entry {
string name;
int number;
};
template<class T> class Vec : public vector<T> {
public:
Vec() : vector<T>() {}
Vec(int s): vector<T>(s){}
T & operator [ ]( int i ) { return at[i]; }
const T& operator[ ]( int i ) const { return at[i]; }
};
Vec<Entry> phone_book(1000);
int _tmain()
{
// TODO: Please replace the sample code below with your own.
Console::WriteLine(S"Hello World");
return 0;
}
----------我什么有下面的编译错误?请多多指教:)
error C2109: subscript requires array or pointer type
test1.cpp(26) : while compiling class-template member function 'Entry &Vec<T>::operator [](int)'
with
[
T=Entry
]
test1.cpp(30) : see reference to class template instantiation 'Vec<T>' being compiled
with
[
T=Entry
]