通过指针的引用查找正方形
To find square by reference of pointers
#include <iostream>
using namespace std;
void square (int *);
int main () {
int number = 0;
cout << " To find the square of the number entered by the user ";
cin >> number;
cout << square (&number);
return 0;
}
void square (int *x)
{
*x = *x ** x;
}
谁能说出这段代码中的错误是什么,因为它给了我一个冗长的奇怪错误
由于square
不返回值,因此它不能向cout
传递任何内容
而是更改行
cout << square (&number);
自
square (&number);
cout << number;
错误在于main()
期望square()
return
结果,而 square 是一个就地修改其参数的void
函数。
错误消息基本上是这样说的:没有operator<<
需要void
因为它是右手论证。
相关文章:
- 正在查找文档以获得PS4平台的C++中的设备信息
- 在C++中查找文件
- 试试完美的正方形,你能给点小费吗
- 模板元程序查找相似的连续类型名称
- 在UNIX系统中使用DIR查找文件的字节大小
- 查找最接近的大于当前数字的数字的索引
- 有没有一种方法可以创建一个带有哈希表的数据库,该哈希表具有恒定时间查找功能
- 查找后更改类变量
- 使用正则表达式regex_search在字符串中查找字符串
- 使用gcc从静态链接的文件中查找可选符号
- 在C++中查找范围的长度
- 算法问题:查找从堆栈中弹出的所有序列
- 在Windows中查找扬声器输出的当前音量级别
- 如何在C++中使用X509证书模在令牌中查找私钥
- 使用.find函数在c++中查找字符和另一个字符之间的大小
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- 查找两个正方形是否共享一条边
- 用于查找给定圆中的正方形数的算法
- 通过指针的引用查找正方形
- 程序查找并打印第一个完全正方形 (i*i),其最后两位数字都是奇数