小编Buc*_*763的帖子

错误:main 声明中有两个或多个数据类型?

对编码非常陌生,所以请理解;)

我基本上试图使用while循环和if语句来制作一个计算器。

#include <iostream>

using namespace std;

int x = 1;
int number;
int total = 0;
int amt = 1;
int a;
int b;
int c;
int d;
string ans;

class OperateClass
Run Code Online (Sandbox Code Playgroud)

我收到错误:“main”声明中有两种或多种数据类型

请解释这意味着什么/如何解决它。

我还想知道是否需要为每个函数创建一个新对象(加、减、乘、除)

请帮忙!

int main()
{

    cout << "Do you want to add, subtract, multiply or divide? I want to : " << endl;
    cin >> ans;

    if(ans == "add"){
        OperateClass opOper;
        opOper.add();

    }else{

        if(ans == "subtract"){
            OperateClass opOper
            opOper.subtract();
                }

    }else{ …
Run Code Online (Sandbox Code Playgroud)

c++ if-statement declaration function while-loop

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

c++ ×1

declaration ×1

function ×1

if-statement ×1

while-loop ×1