Using strings in multiple functions

I'm coding a game, and I need strings to work in all of my functions.

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

/* INCLUSIONS */
#include <iostream>
#include <string>
#include <cmath>

/* DEFEITIONS */
#define pi 3.14159265

/* VARIABLES */
//Program Variables
//All of the strings here are not working. I get the error 'string' does not //have a name type
string versiontype = "Alpha";
double versionnumber = 1.0;
//Stock Variables
string stock1 = "Wellinton Steel";
string stock2 = "Neutron Computers";
string stock3 = "Martyn Paper";
string stock4 = "Hanson Medical";
string stock1ticker = "WELL";
string stock2ticker = "NCOM";
string stock3ticker = "MPAP";
string stock4ticker = "HSMD";
int s1p, s2p, s3p, s4p;



using namespace std;

class GameOperation
{
    public:
        void startGame()
        {
            cout << "Stock Market Game. " << versiontype << " " << versionnumber << endl;
        }
};

class Market
{
    public:
        void displayStock()
        {
            cout << stock1ticker << " " << stock1 << " " << s1p;
            cout << stock2ticker << " " << stock2 << " " << s2p;
            cout << stock3ticker << " " << stock3 << " " << s3p;
            cout << stock4ticker << " " << stock4 << " " << s4p;

        }
}

int main()
{
    GameOperation opObject;
    Market markObject;

    opObject.startGame();
    markObject.displayStock();

    return 0;
}

Topic archived. No new replies allowed.