gpt4 book ai didi

c++ - 为什么 visual studio 在使用 void 作为函数 all 的参数时显示错误 : type name not allowed,?

转载 作者:行者123 更新时间:2023-11-27 23:04:07 24 4
gpt4 key购买 nike

我的 .hpp 文件中有一个具有以下公共(public)方法的类:

virtual void finalize( void ); 

然后我继续调用所述函数:

finalize( void );

我公司的标准要求我放入空占位符。当我在 VS 2010 中构建它时,我得到了

Error   11  error C2144: syntax error : 'void' should be preceded by ')'    

悬停在 void 上的工具提示用红色下划线表示:

Error: type name is not allowed

我已尝试查找此问题,但未找到解决方案。这看起来应该很简单,我想说我以前的代码从来没有出现过问题。

有什么办法解决这个问题吗?

最佳答案

按照贵公司的标准,您的声明是正确的,使用 void 作为类型。

但是,当您调用它 时,您不能只将 void 作为类型传递。你应该这样调用它:

finalize();

关于c++ - 为什么 visual studio 在使用 void 作为函数 all 的参数时显示错误 : type name not allowed,?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24764067/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com