预期构造函数,析构函数或类型转换之前<代币 [英] expected constructor, destructor, or type conversion before < token

查看:80
本文介绍了预期构造函数,析构函数或类型转换之前<代币的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我写了以下程序:


-------------- -------------------------------------------------- ---------------------------------------------


1 #include< stdio.h>

2 #include" abc.h"

3

4 void PROP_abc(double ptr [TN] [TTS])

5 {

6 double ptr1 [TN] [TTS] = {0.1936,0.17273,0.63634,0.9429, 5.4393,0.72777,0.025127,0.14202,0.55906,0.38984,0.00,0.00,0.6214,0.12952,0.45833,00.53225,0.017949,0.57854,0.16608,1.0684,0.31321,1.198,0.00,0.00,0 0.00,0.025592,0.00,0.44234,0.27205, 0.24618,

7 ............

8 ............

9 ............

10 ............

11 ..... .......

12 ............

13 ............

14 ............};

15 for(int i = 0; i< TN; i ++)

16 for(int t = 0; t< TTS; t ++)

17 ptr [i ] [t] = ptr1 [i] [t];

18返回;

19}


---- -------------------------------------------------- -------------------------------------------------- -----


其中TN和TTS在文件abc.h中定义,左边的数字是行号。


我收到以下错误:


函数void PROP_abc

1.错误:预期`}''在行号6中的数字常量之前

2.错误:预期a,a或a; a数字常数在第6行之前


在全球范围内

3.预期不合格-id之前的第15行

4.预期的构造函数,析构函数或类型转换之前<第15行中的令牌

5.在第15行中的++标记之前预期的构造函数,析构函数或类型转换。

6.在<之前的预期构造函数,析构函数或类型转换;第16行中的令牌

7.第16行中++令牌之前的预期构造函数,析构函数或类型转换

8.在第18行返回之前预期的非限定id $>
9.第19行中的预期声明}令牌


我很惊讶看到这么多错误但未能看到原因,请帮忙。


谢谢。

Hi,

I have written the following program:

-------------------------------------------------------------------------------------------------------------

1 #include <stdio.h>
2 #include "abc.h"
3
4 void PROP_abc(double ptr[TN][TTS])
5 {
6 double ptr1[TN][TTS] = { 0.1936, 0.17273, 0.63634, 0.9429, 5.4393, 0.77277, 0.025127, 0.14202, 0.55906, 0.38984, 0.00, 0.00, 0.6214, 0.12952, 0.45833, 00.53225, 0.017949, 0.57854, 0.16608, 1.0684, 0.31321, 1.198, 0.00, 0.00, 0.00, 0.025592, 0.00, 0.44234, 0.27205, 0.24618,
7 ............
8 ............
9 ............
10 ............
11 ............
12 ............
13 ............
14 ............};
15 for(int i = 0; i < TN; i++)
16 for(int t = 0; t < TTS; t++)
17 ptr[i][t] = ptr1[i][t];
18 return;
19 }

-------------------------------------------------------------------------------------------------------------

where TN and TTS are defined in file abc.h and the numbers on left are the line numbers.

I am getting following errors:

In function void PROP_abc
1. error: expected `}'' before numeric constant in line number 6
2. error: expected a,a or a;a before numeric constant in line number 6

At global scope
3. expected unqualified-id before for in line 15
4. expected constructor, destructor, or type conversion before < token in line 15
5. expected constructor, destructor, or type conversion before ++ token in line 15.
6. expected constructor, destructor, or type conversion before < token in line 16
7. expected constructor, destructor, or type conversion before ++ token in line 16
8. expected unqualified-id before return in line 18
9. expected declaration before } token in line 19

I am surprised to see so many errors but fail to see the reason, please help.

Thank you.

推荐答案

你有一个2D数组,所以需要定义每个子数组(行)。

You have a 2D array, so each subarray (row) needs to be defined.

展开 | 选择 | Wrap | 行号


TN和T TS被定义在某个地方吗?


第17行不起作用,因为ptr1不是double的二维数组而是双**。因此,编译器无法正确计算您正在讨论的位置所需的第一个维度大小。
TN and TTS are defined somewhere are they?

Line 17 is not going to work because ptr1 is not a 2 dimensional array of double but rather a double **. As such there is no first dimension size required for the compiler to be able to properly calculate the location you are talking about.



第17行不会起作用,因为ptr1不是double的2维数组,而是double **。因此,编译器无需第一个维度大小即可正确计算您正在讨论的位置。
Line 17 is not going to work because ptr1 is not a 2 dimensional array of double but rather a double **. As such there is no first dimension size required for the compiler to be able to properly calculate the location you are talking about.



ptr1是ptr1 [0]的地址。 ptr1 [0]是TTS双精度数组。因此,ptr1是指向TTS双打数组的指针:


double(* ptr1)[TTS];


ptr1不是双**。


对于数组维度大小,假设TN和TTS是全局常量,编译器确实具有指针算法所需的所有信息。


发布的代码编译好。


发布的错误超出了发布的代码。

ptr1 is the address of ptr1[0]. ptr1[0] is an array of TTS doubles. Therefore, ptr1 is a pointer to an array of TTS doubles:

double (*ptr1)[TTS];

ptr1 is not a double**.


As to array dimension size, assuming TN and TTS are global constants, the compiler does have all the informaton it needs for pointer arithmetic.

The code as posted compiles OK.

The posted errors are outside the posted code.


这篇关于预期构造函数,析构函数或类型转换之前&lt;代币的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆