error: expected unqualified-id before '.' token
error: expected unqualified-id before '.' token
10 struct element
11 {
12 int listnum;
13 char *tablename;
14 char** headl;
15 float** tabledata;
16 struct element *next;
17 };
18
19 struct element *next = NULL;
20 struct element *start= NULL;
21
22 void add_element(char *tablenameadd, char **headladd, float **tableadd, int hcols, int trows, int tcols)
23 {
24 int a=1;
25
26 struct element *pointer;
27
28 element.headl = new char*[hcols];
29 element.tabledata = new float*[trows][tcols];
...
我在 Eclipse 中将其作为 C++ 项目进行调试时遇到错误。我收到的 2 个错误代码都是
expected unqualified-id before '.' token
程序第 28 行和第 29 行
有没有人可以帮忙?
我昨天把它从C项目改成了C++项目。
element
这是您声明的结构,因此您不能这样做
element.headl = new char*[hcols];
element.tabledata = new float*[trows][tcols]
你可以这样做-
void add_element(
char *tablenameadd, char **headladd, float **tableadd,
int hcols, int trows, int tcols)
{
struct element *pointer;
int a = 1;
pointer = new element;
pointer->headl = new char *[hcols];
pointer->tabledata = new float *[tcols * trows];
}
声明
element.headl
是错误的,因为 element 是数据类型的名称,而您试图操作以名称 pointer 定义的结构,因此您必须更改它至:
struct element *pointer;
pointer->headl = new char*...
10 struct element
11 {
12 int listnum;
13 char *tablename;
14 char** headl;
15 float** tabledata;
16 struct element *next;
17 };
18
19 struct element *next = NULL;
20 struct element *start= NULL;
21
22 void add_element(char *tablenameadd, char **headladd, float **tableadd, int hcols, int trows, int tcols)
23 {
24 int a=1;
25
26 struct element *pointer;
27
28 element.headl = new char*[hcols];
29 element.tabledata = new float*[trows][tcols];
...
我在 Eclipse 中将其作为 C++ 项目进行调试时遇到错误。我收到的 2 个错误代码都是
expected unqualified-id before '.' token
程序第 28 行和第 29 行
有没有人可以帮忙?
我昨天把它从C项目改成了C++项目。
element
这是您声明的结构,因此您不能这样做
element.headl = new char*[hcols];
element.tabledata = new float*[trows][tcols]
你可以这样做-
void add_element(
char *tablenameadd, char **headladd, float **tableadd,
int hcols, int trows, int tcols)
{
struct element *pointer;
int a = 1;
pointer = new element;
pointer->headl = new char *[hcols];
pointer->tabledata = new float *[tcols * trows];
}
声明
element.headl
是错误的,因为 element 是数据类型的名称,而您试图操作以名称 pointer 定义的结构,因此您必须更改它至:
struct element *pointer;
pointer->headl = new char*...