I'm Pretty New With C++, All I Know I've Learnt From Internet(Yay), and Last time I "Programmed" Was a half a year ago, but now I've decided to give it a try again. And Basically I've decided to refresh my memory with a simple calculator, and i've run into a problem with switch function, which I've never used before, I always like If more, but people say it's more convienient, and I get error saying:"case label does not reduce to an integer constant".
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
string Pirmas; //Pirmas = First In English
string Antras; // Second
string Trecias; // Third
int a,b,c;
int main() {
cout << "Paprastas Skaiciuotuvas V1!"<< endl; // Simple Calculator
cout << "*********************************"<<endl;
cout <<"Iveskite Pirmaji Skaitmeni!:"<< endl; // Enter First Numeral
getline(cin,Pirmas);
stringstream(Pirmas) >> a;
cout <<"Iveskite Antraji Skaitmeni!:"<<endl; // Enter Second Numeral
getline(cin,Antras);
stringstream(Antras)>> b;
cout<<"Iveskite Matematini Zenkla!(+-*/):"<<endl; // Enter Arithemic Sign
getline(cin,Trecias);
stringstream(Trecias)>>c;
switch(c){
case "+":
cout<<"Atsakymas: "<<a+b<<endl; // Answer
break;
case "-":
cout<<"Atsakymas: "<<a-b<<endl;
break;
case "*":
cout<<"Atsakymas: "<<a*b<<endl;
break;
case "/":
cout<<"Atsakymas: "<<a/b<<endl;
break;
};
return 0;
}
Thank You. P.S Coding Is Amazing