预期的类型说明符,并且不能在初始化时转换"int *" [英] expected type-specifier and cannot convert ‘int*’ in initialization
问题描述
我有大量的代码,因此我尝试仅在此处包括代码的相关部分
I have a large amount of code, so I have tried to only include the relevant parts of the code here
当我的cpp文件包含在另一个cpp文件中时,编译没有问题.
My cpp files compiled with no problems when they were included in another cpp file.
我还有另一个文件.之前,这个编译很好,直到我尝试将上面的文件包括在
I have another file called. This compiled fine before, until I tried to include the files above in
我得到了未定义的参考错误,即使它们是在cpp文件中定义的
I get undefined reference errors, even though they were defined in the cpp file
这是怎么回事?有链接错误吗?我需要在makefile中进行更改吗?
What is going on? Is there a linkage error? Do I need to make changes in the makefile?
推荐答案
使用
ASp* asp = new ASp(input);
为我工作.不确定为什么使用
works for me. Not sure why using
ASp* asp = new ASp::ASp(input);
是个问题.需要进一步挖掘以找出答案.
is a problem. Need to dig further to find out.
更新
使用main(C ++)中的声明在中解决了同一问题.该问题的工具链是MS Visual Studio.那里的答案指出了相同的问题,但是没有解释为什么new Asp::Asp(input);
将是int*
类型. OP报告的错误消息似乎是g++
特定的错误消息.
The same problem was addressed at using declarations in main (C++). The tool chain for that question is MS Visual Studio. The answers there point out the same problem but there is no explanation of why new Asp::Asp(input);
would be of type int*
. The error message reported by the OP appears to be a g++
specific error message.
这篇关于预期的类型说明符,并且不能在初始化时转换"int *"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!