#include <iostream>
#include <vector>
int main()
{
class Int {
public:
Int(int _i) : i(i) {}
private:
int i;
};
std::vector<Int> VI;
}
Я пытаюсь скомпилировать код выше и получил следующее сообщение об ошибке:почему создает локальный вектор типа сбой
foo.cc: In function 'int main()':
foo.cc:13: error: 'main()::Int' uses local type 'main()::Int'
foo.cc:13: error: trying to instantiate 'template<class _Alloc> class std::allocator'
foo.cc:13: error: template argument 2 is invalid
foo.cc:13: error: invalid type in declaration before ';' token
Может кто-нибудь из вас сказать мне, почему я не могу сделать что-то вроде этого в C++? Заранее спасибо.
Не тот же вопрос, но другой вопрос по той же проблеме: [с использованием локальных классов с алгоритмами stl] (http://stackoverflow.com/questions/742607/using-local-classes-with-stl-algorithms) –