Help in var!!

Hi world.

I have one problem in my new project...
One part of the code is this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>

using namespace std;

int name, yourobject, score, comscore;
void process();

int main()
{
    cout << "\n Ingrese su nombre >>> ";
    cin >> name;
    process();
}

void process()
{
    system("cls");
    cout << "\n Puntuacion de " << name << " : " << score << " - Puntuacion de COM : " << comscore;
    cout << "\n Selecciona que quieres tirar\n [1] Papel    [2] Piedra  [3] Tijera\n\n >>> ";
    cin >> yourobject;
    if (yourobject == 1)
    yourobject = "Papel";
    if (yourobject == 2)
    yourobject = "Piedra";
    if (yourobject == 3)
    yourobject = "Tijera";
}
...


Okay, the error is in the 22, 24 and 26 line. I don't know it; the vars are perfectly written. (No are consts) ... What is the error???

HELPP MEE PLEASE
yourobject = "Papel";

yourobject is of type int. A number. How can you possibly try to set this number to the value "Papel"?
OH, true I did not remember... Int is only for numbers. What is the variable for the hexadecimal words?? I know that types of variables : int, short, long, char, float, doble, bool.
I think is char, right?

Regards
In C++, we have string.
Well, the solution is change the "int" for "string" where I written the variables??
If you want the user to enter a number, have a variable to store than number. If you want to store a string, have a different variable for storing that string.
Yeah, now I already understand xDD

I make the code with other system, also is workable.

See; http://codepad.org/0GlNJfy5

It is good, no?

Regards and thank you!
Last edited on
Topic archived. No new replies allowed.