function - 我应该按照问题陈述打印 5,4,3,2,1,但是我的 c++ 代码显示了一些错误
问题描述
我得到的错误
F:\coding\code blocks\hello.cpp|14|error: no match for 'operator<<' (操作数类型是 'std::ostream {aka std::basic_ostream}' 和 'void')|
我的代码
#include <iostream>
using namespace std;
void fun(int n)
{
if (n==0) return;
cout<<n<<endl;
fun(n-1);
}
int main()
{
cout << fun(5)<< endl;
}
解决方案
int 主要功能。而不是写
cout<<fun(5)<<endl;
像这样写。
有趣(5);
推荐阅读
- vb.net - 为什么我的 VB 程序抛出异常,抱怨 OleDbDataReader 已关闭,而它应该绝对打开?
- windows - 为什么我在任务计划程序中看不到我的任务
- css - 自动换行,分词 php html css
- python - Python groupby 在创建 bin 后返回 NaN 平均值
- c# - 下载许多视频后,HttpClient 中的 await httpClient.GetByteArrayAsync() 突然停止?
- curl - 清除 AWS Neptune 中的数据
- node.js - 如何使用带有 Express 的脚手架 Nuxt 应用程序测试服务器 api 端点?
- scala - 具有多行的 libraryDependencies
- .net - 缺少 AppSettings.json 文件数据
- amazon-web-services - 更新 Kubernetes 部署映像不起作用