代码一直说:“[错误]无法将参数'1'的'float*'转换为'float'到'void test(flo
Code Keeps saying: "[Error] cannot convert 'float*' to 'float' for argument '1' to 'void test(float, int)'"
#include <iostream>
using namespace std;
void test(float, int);
int main()
{
const int size=11;
float a[size];
test(a, size);
return 0;
}
void test(float a[], int size)
{
[....]
}
它指向测试(a,大小);但我无法弄清楚出了什么问题(我也在学习编码,刚刚了解数组/困惑)
您的函数原型void test(float, int);
与您的函数void test(float a[], int size)
不匹配。将顶部的原型更改为void test(float a[], int size);
(为了保持一致性,我喜欢将输入变量名称保留在原型中,但这不是必需的)。
你可能想写:
void test(float*, int);
// ...
void test(float* a, int size)
{
[....]
}
当使用数组参数调用 test 时,数组将衰减为指向其第一个元素的指针 - 并且其大小将丢失。
测试前向减速的参数类型错误。
试试这个。
#include <iostream>
using namespace std;
void test(float *, int);
int main()
{
const int size=11;
float a[size];
test(a, size);
return 0;
}
void test(float a[], int size)
{
}
相关文章:
- 没有合适的构造函数可以从"float"转换为"_D3DCOLORVALUE"
- 错误:无法将"float*"转换为"float"
- 有没有一种优雅的方法可以将矢量<复杂<float>>转换为矢量<short>?
- MBED RTOS将Float转换为字符串/字符阵列
- 错误:无法将参数"1"的"float*"转换为"float"
- 有没有快速的方法可以将std::vector<std::vector<float>>转换为std::vector<float2>?
- 将 const float* 转换为 std::array<float, ...>
- 当float转换为int时,此代码中是如何/为什么进行缩小的
- Arduino 无法在初始化时将'float'转换为'const char*'
- C++11自动.从float转换为long
- g++ 在不使用 -Wconvert 的情况下将 double/float 转换为无符号整数时发出警告
- 从 std::vector<std::vector<float>> 转换为 float**
- 在opencv中将垫子转换为矢量<float>和矢量<float>转换为垫子
- 代码一直说:“[错误]无法将参数'1'的'float*'转换为'float'到'void test(flo
- 从'float'转换为'LONG'需要缩小转换范围
- 错误:初始化时无法将'float*'转换为"qreal* {aka double*}"
- Int16_t到float转换的奇怪
- 使用JNI将float*转换为jfloatArray
- 将google::p rotobuf::RepeatedField<float>转换为浮动
- 将float转换为int时的奇怪行为