2017-02-01 13 views
2

ためmain.cppに一致を修正しないように見ると、ここにコードがある:`のstd ::はistream&起動するには<< INT&」演算子

#include <iostream> 
#include <stdlib.h> 
using namespace std; 

int add(int x,int y){ 
    return x+y; 
} 

int sub(int x,int y){ 
    return x-y; 
} 

int divide(int x,int y){ 
    return x/y; 
} 

int mult(int x,int y){ 
    return x*y; 
} 

void operation(string operation,int x,int y){ 
    if(operation=="addition"){ 
     cout << add(x,y); 
    } 
    else if(operation=="subtraction"){ 
     cout << sub(x,y); 
    } 
    else if(operation=="multiplication"){ 
     cout << mult(x,y); 
    } 
    else if(operation=="division"){ 
     cout << divide(x,y); 
    } 
} 
int main(int argc, char *argv[]){ 
    while(true){ 
    string operation; 
    int x; 
    int y; 
    cout << "Please enter your operation: "; 
    cin >> operation; 
    cout << endl << "Please enter the first number: "; 
    cin << x; 
    cout << endl << "Please enter the second number: "; 
    cin << y; 
    cout << endl; 
    operation(operation,x,y) 
    } 
    } 
    system("PAUSE"); 
    return 0; 
} 

私がいる問題は、私はXを持つようにしたいということですとyは、ユーザーがcinを使用して入力しますが、何らかの理由でタイトルにエラーが表示されます(main.cppは `std :: istream & < < int & 'と一致しません)私は変数を初期化する方法でそれが他の何かになるかどうかわかりません。

ありがとうございました!

+3

'cin >> x;'と 'cin >> y;'にする必要があります。 – songyuanyao

+0

助けてくれてありがとう! –

答えて

関連する問題