I'm learning c++ and trying some things out... The following code is giving me a compile time error, can anyone explain to me why, I'm a little confused... I'm assuming it's the cin >> playagain
statement. Thank you for the help. (also if I'm making any other general c++ mistakes, please let me know)
heres the error:
Error 1 error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion) c:\users\abdo\documents\visual studio 2012\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 45 1 ConsoleApplication1
anyways, including #include <string>
fixed the problem, thank you 0x499602D2
#include "stdafx.h"
#include <iostream>
using namespace std;
class calculatorc1 {
public:
calculatorc1();
~calculatorc1();
int multnums(int a, int b);
protected:
int result;
};
calculatorc1::calculatorc1() {
}
calculatorc1::~calculatorc1() {
}
int calculatorc1::multnums(int a, int b) {
int result = a * b;
return result;
}
int main()
{
string playagain;
bool calcing = true;
while (calcing) {
calculatorc1 c;
int x;
int y;
cout << "first num\n";
cin >> x;
cout << "second\n";
cin >> y;
cout << c.multnums(x, y) << "\n";
cout << "mul again? (y/n)\n";
cin >> playagain;
if (playagain == "n") {
calcing = false;
system("pause");
}
}
}