我在Linux上用GCC 4.8.4編譯(使用-std = C++ 0x -fPIC)。不能與GCC一起使用數組
我想用一個由我定義的數組,但我收到此錯誤:
class value
{
public:
typedef std::vector<value> array;
typedef std::map<std::string, value> object;
protected:
int type_;
union
{
...
array* array_;
};
typedef value::array array;
}
class ErrorMessage
{
array my_array;
}
編譯錯誤:
/usr/include/c++/4.8/array:81:12: note: template<class _Tp, long unsigned int _Nm> struct std::array
struct array
^
../sources/ErrorMessage.h:290:2: error: ‘array’ does not name a type
array my_array;
有一種方法來解決這個問題? (與GCC 4.4.7它的工作)
謝謝。
您不會爲其聲明或大小聲明類型。一個什麼樣的數組?奶牛?字符?飛機? –
您似乎正在使用['std :: array'](http://en.cppreference.com/w/cpp/container/array),它是*模板*結構。您需要提供模板參數。 –
我認爲OP可能已經忘記了在編輯之前讓問題變得更有意義的*一行。 –