C++ 在函数声明中错误两种或多种数据类型

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19609330/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 22:59:52  来源:igfitidea点击:

C++ error two or more data types in declaration of function

c++

提问by Dhiral Pandya

In a piece of code I am passing two parameters both of same type b2Vec2 *

在一段代码中,我传递了两个相同类型的参数 b2Vec2 *

void bool isVelocityAllowToCar(b2Vec2 *newVelocity, b2Vec2 *preVelocity);

When I build my project it showing me following error.

当我构建我的项目时,它显示了以下错误。

two or more data types in declaration of 'isVelocityAllowToCar'

What am I doing wrong?

我究竟做错了什么?

回答by Daniel Frey

The problem is the return type you specify. void boolis not valid, it's two types voidand bool. You just need to remove the voidand it should work:

问题在于您指定的返回类型。void bool无效,它有两种类型voidbool。你只需要删除它void,它应该可以工作:

bool isVelocityAllowToCar(b2Vec2 *newVelocity,b2Vec2 *preVelocity);