String Variable has value?

Hello, is it possible for a string variable to have a value like the number 1? Or like the code below?
1
2
3
4
5
  string food[] = {"Burger","Fries","Pasta"};

Burger = 100;
Fries = 200;
Pasta = 300;
Yes, and no... What you have is an array.
food[0] = "Burger";
food[1] = "Fries";
food[2] = "Pasta";

Then you have 3 integer variables set to a value
int Burger=100;
int Fries =200;
int Pasta=300;
Now you can add Burger + Fries to get a value of 300...

A string hold characters....
string Burger ="1";
string Fries="2";
string Pasta="3";

They have no numeric value. You can't add Burger and Fries to get 3 this way. You may convert the string to an integer. or use Enum, but a string holding an integer is not allowed in c++ to the best of my knowledge.
Last edited on
Oh ok, thank you for your reply, I'll keep it in mind :)
Topic archived. No new replies allowed.