[英]Illegal use of this type as an expression
class dataReader{
private:
ifstream gfxDataFile;
int numVertices;
vector<*vertexData> vertices;
public:
dataReader();
dataReader(string file);
~dataReader();
string getLine();
int numberOfVertices();
};
the line with the vector gives me the error 向量行给我错误
vertexData: Illegal use of this type as an expression, any help guys? vertexData:非法使用此类型作为表达式,对您有帮助吗?
Heres the definition of vertexData 这是vertexData的定义
class vertexData{
private:
float x;
float y;
float z;
public:
vertexData();
vertexData(float gx, float gy, float gz);
~vertexData();
float getX();
float getY();
float getZ();
};
*vertexData
should be vertexData*
*vertexData
应该是vertexData*
Putting the *
on the left means, broadly, 'try to dereference the following expression' - and of course what follows is not a valid expression (though even if it were you'd have other problems trying to use an expression inside a template argument list...). 在左边加*
的含义是,“尝试取消引用以下表达式”-当然,后面的表达式也不是有效的表达式(尽管即使您尝试在模板参数中使用表达式也遇到其他问题清单...)。 When declaring pointer types the *
goes on the right of the type name. 声明指针类型时, *
在类型名称的右侧。
Write *
after the type: 在类型之后输入*
:
vector<*vertexData> vertices; //wrong syntax
vector<vertexData*> vertices; //correct syntax
As a sidenote, I don't think you need a vector of pointers. 作为附带说明,我认为您不需要指针向量。
Why don't you use this: 你为什么不使用这个:
vector<vertexData> vertices;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.