有下面兩個C++結構:
struct Vertex3D{
GLfloat x;
GLfloat y;
GLfloat z;
Vertex3D(GLfloat a, GLfloat b, GLfloat c){
x = a;
y = b;
z = c;
}
};
struct Triangle3D{
Vertex3D v1;
Vertex3D v2;
Vertex3D v3;
Triangle3D(Vertex3D vt1, Vertex3D vt2, Vertex3D vt3){
};
};
Vertex3D
的構造函數正常,Triangle3D
的構造出現警告:“Constructor for 'Triangle3D'' must explicitly initialise member 'v2' which does not have default constructor”
但是我已經為Vertex3D
類型結構創建了一構造函數,為什麼還會出現這類錯誤呢?應該怎麼解決?謝謝
你再Vertex3D裡再加個空參數空內容的構造函數進去試試