Using Stored Values

Hello. I'm a beginner to C++.
I'm trying to make a simple program whereby the system asks the user a series of questions, whilst the user enters a "0" or a "1" to reply to each of those questions. Each question is interralted to the question previously asked, hence, the system uses switches and cases, and the questions are asked perfectly. In theory, after the questions are asked, the system announce a statement at the end that will be dependent on the way the user answered the questions. Thus, the system needs a way to collect and store the answers that the user entered in. However, I can't find a way to do this. Probably the main reason is because the system will have a lot of cases in switches, and switches in for loops, and my functions do not connect to each other.
The sample are functions hooked onto the system already, where theoretically, SetDecisionData is suppose to store "x". When I need to use "x", I would just need to use GetDecisionData to return the value of "x". But, when I use the latter, the system will always and only print out "0" instead of "0" or "1"

1
2
3
4
5
6
7
int outPutx;
    void SetDecisionData(int x){
        x = outPutx;
    }
    void GetDecisionData(){
        cout << outPutx << endl;
    }


Any suggestions will be awesome. What am I doing wrong?
You could always use a container to store these answers.
I would probably use std::vector to do so, but that might be a bit too much if you're a beginner.
Have you learned about arrays? You could use an array to store them, but at the beginning level you will only be able to have an array size that doesn't change. So, if you set it up to store 100 answers, it will only be able to store 100 answers. If you know how to dynamically allocate an array, you could do that so that you could store as many answers as you want in arrays (just be sure to avoid memory leaks).

Check out http://www.cplusplus.com/doc/tutorial/arrays/ for info on arrays.

I'm sorry if you already know this stuff - I don't know how extensive your understanding of C++ is.

There are multiple ways to write a program like the one that you are writing, so use a method that makes the most sense to you.
Topic archived. No new replies allowed.