template <typename T>
class MyArray
{
private :
vector<T> arr;
public:
MyArray(){}
MyArray(const initializer_list<T> il)
{
for (auto x : il)
{
arr.push_back(x);
}
}
};
MyArray<int> foo = {4, 5, 6, 9};
这样写了之后, for (auto i : foo) cout << i << endl; 提示
error: 'class MyArray<int>' has no member named 'begin'|
请朋友们指点.