Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/129.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
关于非类类型错误的问题? 我是C++新手,我一直在尝试处理输入的级联。我有一个用户输入的名字和姓氏以及假社会保险的最后四位数字。然后我想把它们加在一起,取名字的第一个字母,姓氏的第一个字母和四个数字。每次我运行程序时,非类类型的错误就会弹出。 错误: 函数'int main()':89:26:错误:请求'firstname[i]'中的'at'成员,该成员为非类类型'string2{aka char[3]}'90:26:错误:请求'lastname[i]'中的'at'成员,该成员为非c`在此处输入代码'lass type'string2{aka char[3]}' typedef char string2[大小]; string2 firstname[大小]; string2 lastname[大小]; 字符串2初始[大小]; string2 lastfour[尺寸]; //ID的浓缩 字符串id[大小]; 对于(int i=0;i_C++_Types_Compiler Errors_Concatenation - Fatal编程技术网

关于非类类型错误的问题? 我是C++新手,我一直在尝试处理输入的级联。我有一个用户输入的名字和姓氏以及假社会保险的最后四位数字。然后我想把它们加在一起,取名字的第一个字母,姓氏的第一个字母和四个数字。每次我运行程序时,非类类型的错误就会弹出。 错误: 函数'int main()':89:26:错误:请求'firstname[i]'中的'at'成员,该成员为非类类型'string2{aka char[3]}'90:26:错误:请求'lastname[i]'中的'at'成员,该成员为非c`在此处输入代码'lass type'string2{aka char[3]}' typedef char string2[大小]; string2 firstname[大小]; string2 lastname[大小]; 字符串2初始[大小]; string2 lastfour[尺寸]; //ID的浓缩 字符串id[大小]; 对于(int i=0;i

关于非类类型错误的问题? 我是C++新手,我一直在尝试处理输入的级联。我有一个用户输入的名字和姓氏以及假社会保险的最后四位数字。然后我想把它们加在一起,取名字的第一个字母,姓氏的第一个字母和四个数字。每次我运行程序时,非类类型的错误就会弹出。 错误: 函数'int main()':89:26:错误:请求'firstname[i]'中的'at'成员,该成员为非类类型'string2{aka char[3]}'90:26:错误:请求'lastname[i]'中的'at'成员,该成员为非c`在此处输入代码'lass type'string2{aka char[3]}' typedef char string2[大小]; string2 firstname[大小]; string2 lastname[大小]; 字符串2初始[大小]; string2 lastfour[尺寸]; //ID的浓缩 字符串id[大小]; 对于(int i=0;i,c++,types,compiler-errors,concatenation,C++,Types,Compiler Errors,Concatenation,您使用的变量都声明为char[][]。要使用at(),您需要选择std::string,因为它是该类的成员函数 或者,您可以使用操作符[]访问jth条目的ith字符,例如,firstname[j].[i]尝试firstname[i][0]。 In function 'int main()': 89:26: error: request for member 'at' in 'firstname[i]', which is of non-class type 'string2 {aka char

您使用的变量都声明为
char[][]
。要使用
at()
,您需要选择
std::string
,因为它是该类的成员函数


或者,您可以使用
操作符[]
访问
j
th条目的
i
th字符,例如,
firstname[j].[i]

尝试
firstname[i][0]
In function 'int main()': 89:26: error: request for member 'at' in 'firstname[i]', which is of non-class type 'string2 {aka char [3]}' 90:26: error: request for member 'at' in 'lastname[i]', which is of non-c`enter code here`lass type 'string2 {aka char [3]}' 
typedef char string2[size];
string2 firstname[size];
string2 lastname[size];
string2 middleinitial[size];
string2 lastfour[size];


//CONCATINATION FOR ID
string id[size];
for (int i = 0; i < size; i ++)
{
   id [i] = firstname[i].at (0);//set id = to first letter of the first name
   id [i] += lastname[i].at (1);//concatinate the first letter of the last name to the id
   id [i] += lastfour[i]; //concatinate the last four 
}