C++ 不是“gcc 4.5.2编译器错误”的直接基础
我有这个密码C++ 不是“gcc 4.5.2编译器错误”的直接基础,c++,C++,我有这个密码 #include <vector> #include <array> template <typename T> struct Vertice { T elements_[4]; Vertice(const T & x, const T & y, const T & z) { elements_[0] = x; elements_[1] = y;
#include <vector>
#include <array>
template <typename T>
struct Vertice
{
T elements_[4];
Vertice(const T & x, const T & y, const T & z)
{
elements_[0] = x;
elements_[1] = y;
elements_[2] = z;
elements_[3] = T(1);
}
Vertice() : Vertice(T(0), T(0), T(0)) {}
};
typedef Vertice<float> VerticeF;
std::array<VerticeF, 5> v2;
使用gcc 4.5.2编译时返回以下错误:
$ g++ -o tutorial tutorial.cpp -std=gnu++0x
tutorial.cpp: In constructor ‘Vertice<T>::Vertice() [with T = float]’:
/usr/include/c++/4.5/tr1_impl/array:50:5: instantiated from here
tutorial.cpp:28:41: error: type ‘Vertice<float>’ is not a direct base of ‘Vertice<float>
但是,如果我不使用构造函数委托,它将正常工作
为什么?GCC4.5不支持构造函数委托;您需要使用GCC4.7;请参阅。GCC 4.5不支持构造函数委托;您需要使用GCC4.7;请参阅。如果您看到,您将看到GCC 4.5不支持委托构造函数。如果您看到,您将看到GCC 4.5不支持委托构造函数。您刚刚让我免于写问题。谢谢你,你刚才救了我一个问题。非常感谢。