c++ - 为什么会出现 invalid operands 的问题?

查看:287
本文介绍了c++ - 为什么会出现 invalid operands 的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

代码运行的时候出现了 invalid operands of types 'int (int, int)' and 'int' to binary 'operator<< ' 的错误。
代码如下:

//把M个同样的苹果放在N个同样的盘子里,允许有盘子空着,一共有几种放法?
#include <iostream>

using namespace std;

int count(int m, int n)
{
    if (m <=1 || n <=0) return 1;
    if (m < n)
        return count(m, m);
    else
        return count(m, n-1)+count(m-n, n);
}

void prime()
{
    int apples, plates;
    cin >> apples >> plates;
    count << count(apples, plates);
}

在count<< count(apples, plates),即倒数第二行处提示错误,为什么会出现这种类型的错误呢?

解决方案

cout << count(apples, plates);

这篇关于c++ - 为什么会出现 invalid operands 的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆