2013-01-23 39 views
0

我有這樣的代碼「不是直接基」 GCC 4.5.2編譯器錯誤

#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> 

但是,如果我不使用構造函數代理,工作正常。

爲什麼?

+1

如果您看到[此鏈接](http://gcc.gnu.org/gcc-4.5/cxx0x_status.html),您將看到GCC 4.5不支持委派構造函數。 –

回答