Howdy guys,
so i am trying to use Case operation on a String ,is Case operators only works with Integers ? Because the compiling error :
switch quantity not an integer
And i have this code as an example :
#include <iostream>
using namespace std;
int main(){
string type;
cout<<"Please enter your computer type (PC ,Laptop, Smartphone) : "<<endl;
getline(cin, type);
switch(type){
case "PC":
cout<<"Ok so you'vr got a "<<type;
break;
case "Laptop":
cout<<"Aha ,u got a "<<type;
break;
case "Smartphone":
cout<<"That s not bad ,u ve got :"<<type;
break;
}
return 0;
}
I know that i can use other logical operators like IF ; but i am stydying the Case operators so i am curious can i work with Strings or not.