它不是编译.我正在调用一个通过引用调用的函数,但有一个错误,无法将双*转换为双倍
it is not compiling. I am calling a function which is called by reference but there is an error which is can not convert double * to double
#include<iostream.h>
#include<conio.h>
void square(double);
void main()
{
clrscr();
double x;
x=123.456;
cout<<"nThe value of i before calling square(), is :"<<x;
cout<<endl;
square(&x);
cout<<"The value of i after calling square(), is :"<<x;
cout<<endl;
getche();
}
void square(double* x)
{
*x=*x**x;
}
它不起作用,为什么?
它也没有编译。
我正在调用一个called by reference
但有一个错误,即
无法将双 * 转换为双倍
square
的声明和定义在参数类型上有所不同:
void square(double);
// ...
void square(double* x) { /* ... */ }
square(&x)
尝试使用double*
调用void square(double)
- 这解释了您的错误。
您还使用了古老的C++编译器 - iostream.h
和conio.h
是非标准且过时的。
您对指针的使用也是非惯用的 - square
应按值或const
值引用double
。
相关文章:
- 我的 cout 上有一个奇怪的输出,它把答案放在第一位,然后在我调用它的地方放一个奇怪的输出.我该怎么办?
- 我有一个调用ID3D11DeviceContext::CopySubresourceRegion的循环.我怎么能强制等待
- 编译器错误:函数调用在常量表达式中必须有一个常量值
- 为什么只有在向量中已经有一个元素时才调用移动构造函数?
- 我有一个CEdit盒子.当我禁用该框并在尝试调用 SetReadOnly 后立即将其禁用状态.这是为什么
- 它不是编译.我正在调用一个通过引用调用的函数,但有一个错误,无法将双*转换为双倍
- C++ 为什么这些构造函数调用中有 3 个有效,但有一个不起作用?
- 通过初始化列表调用另一个类的构造函数.有问题
- 为什么 C++ 数组的大小不能有一个返回常量的函数调用
- 是否有一个 CoreFoundation 等效项在调用 [[NSBundle mainBundle] bundlePat
- 编译器声明调用没有匹配的函数,即使原型中有一个
- 删除和自由在C++中有什么区别,C++的默认析构函数调用哪一个?
- 是否有可能有一个基类方法来调用它的所有派生类的相同(但被重写的方法)?
- 我们有一个向量,但不清楚调用了哪个构造函数
- Java - 我有一个库(.a/.so)和header(.h),如何使用Java调用它们的函数?
- 我有一个C++2d数组,我必须调用函数.它只对每5个位置进行平均,例如[0][0]+[5][0]这看起来是否正确,或者有
- 我有一个引用,想调用一个需要 boost::shared_ptr 的函数
- 当您有一个二维数组(C++)时调用析构函数的正确方法是什么?
- 从Cocos2d::Layer派生的类有一个指针数据成员.这个元素也有一个向量容器.调用vector::push_bac
- 如果您有一个调用其他内部函数的类接口函数