c++ - 为什么会出现 invalid operands 的问题?
天蓬老师
天蓬老师 2017-04-17 13:58:53
0
4
1350

代码运行的时候出现了 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),即倒数第二行处提示错误,为什么会出现这种类型的错误呢?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(4)
左手右手慢动作

cout << count(apples, plates);

左手右手慢动作

count << count(apples, plates);
The left side is the function<<The right side is the int type

Is this possible?

迷茫

First tell me the reason why you use it this way

小葫芦

Sorry, I changed cout to count

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!