[英]C++ Struct - Error 1 error C2143: syntax error : missing ';' before '*'
when i try to compile the following, i receive the error "Error 1 error C2143: syntax error : missing ';' 当我尝试编译以下内容时,出现错误“错误1错误C2143:语法错误:缺少';' before '*'". 在“ *”之前”。 Does anyone know why am i receiving this error? 有谁知道我为什么收到这个错误? What am i doing wrong here? 我在这里做错了什么?
struct HE_edge {
HE_vert* vert; // vertex at the end of the half-edge<br>
HE_edge* pair; // oppositely oriented half-edge<br>
HE_face* face; // the incident face<br>
HE_edge* prev; // previous half-edge around the face<br>
HE_edge* next; // next half-edge around the face<br>
};
struct HE_vert {
float x, y, z; // the vertex coordinates<br>
HE_edge* edge; // one of the half-edges emanating from the vertex<br>
};
struct HE_face {
HE_edge* edge; // one of the half-edges bordering the face<br>
};
Try to declare your structs in the right order : Since HE_edge depends on HE_vert and HE_face, declare them before. 尝试以正确的顺序声明结构:由于HE_edge依赖于HE_vert和HE_face,因此请先声明它们。
struct HE_vert;
struct HE_face;
struct HE_edge {
HE_vert* vert; // vertex at the end of the half-edge<br>
HE_edge* pair; // oppositely oriented half-edge<br>
HE_face* face; // the incident face<br>
HE_edge* prev; // previous half-edge around the face<br>
HE_edge* next; // next half-edge around the face<br>
};
struct HE_vert {
float x, y, z; // the vertex coordinates<br>
HE_edge* edge; // one of the half-edges emanating from the vertex<br>
};
struct HE_face {
HE_edge* edge; // one of the half-edges bordering the face<br>
};
You need to forward declare HE_vert
and HE_face
before you use them in HE_edge
. 您需要先声明HE_vert
和HE_face
然后才能在HE_edge
使用它们。
// fwd declarations. Can use "struct" or "class" interchangeably.
struct HE_vert;
struct HE_face;
struct HE_edge { /* as before */ };
You need to declare all the classes before you use their types to make pointers: 您需要先声明所有类,然后再使用它们的类型来创建指针:
struct HE_edge;
struct HE_vert;
struct HE_face;
// your code
You must declare identifiers before you use them. 使用标识符之前,必须先声明标识符。 For structures this is simply done by eg 对于结构,只需通过例如
struct HE_vert;
Place that before the definition of HE_edge
. 将其HE_edge
的定义之前。
The first declaration has no idea what HE_vert
and HE_face
is, to you need to tell the compiler what are those: 第一个声明不知道HE_vert
和HE_face
是什么,您需要告诉编译器这些是什么:
struct HE_face;
struct HE_vert;//tell compiler what are HE_vert and HE_face
struct HE_edge {
HE_vert* vert; // vertex at the end of the half-edge<br>
HE_edge* pair; // oppositely oriented half-edge<br>
HE_face* face; // the incident face<br>
HE_edge* prev; // previous half-edge around the face<br>
HE_edge* next; // next half-edge around the face<br>
};
struct HE_vert {
float x, y, z; // the vertex coordinates<br>
HE_edge* edge; // one of the half-edges emanating from the vertex<br>
};
struct HE_face {
HE_edge* edge; // one of the half-edges bordering the face<br>
};
Razvan. 拉兹万
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.