need help with classes and headers

I have a final due friday and i'm really trying to impress my teacher. I've been studying header files and using classes. Trying to make a War Games global thermo nuclear warfare game but i'm having trouble whenever I run the program it displays something i can't figure out. i will post the files but please help me
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
  //
//  Maps.h
//  Global ThermoNuclear Warfare
//
//  Created by Zachary Philipp on 4/27/17.
//  Copyright © 2017 Zachary Philipp. All rights reserved.
// if ya can't get the headers to work just copy and paste them to the main.cpp and run it 
#include <iostream>
using namespace std;

#ifndef Maps_h
#define Maps_h
//USA info begin
char USA_map[11][29]=
{
    {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','/',' ','\\'},
    {' ',' ','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',' ',' ',' ','_',' ',' ',' ',' ','/',' ',' ','|'},
    {' ','/','s','e','a',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','\\','_','/',' ','L','_','_','/',' ',' ',' '},
    {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '},
    {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','/',' '},
    {' ','\\',' ',' ',' ',' ',' ',' ',' ',' ',' ','*','U','S','A','*',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','/',' '},
    {' ',' ','|',' ',' ',' ',' ','d','e','n',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','a','t','l',' ','|',' '},
    {' ',' ','\\',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','_','_',' ','\\',' ',' '},
    {' ',' ',' ','\\','_','_','_','_','_','_','_','_','_',' ',' ',' ',' ',' ',' ',' ','/','\\','/',' ',' ','\\',' ','\\',' '},
    {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','\\',' ',' ',' ',' ',' ','/',' ',' ',' ',' ',' ',' ','\\','/',' '},
    {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','\\','_','_','_','/',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '},
};
/*
ideal map image
                              / \
      _______________   _    /  |
     /               \_/ \__/   |
    |                          |
    |                          /
     \            USA          /
      |                        |
      \                     __ \
        \_________       /\/  \ \
                  \     /      \/
                   \___/
 1. Seattle cord    [2][2],[2][3],[2][4]
 2. Denver cord     [6][7],[6][8],[6][9]
 3. Atlanta cord    [6][23],[6][24],[6][25]
*/
//function to show the current map of US
void display_USA()
{
    int rows = 11;
    int col = 29;
    for (int x = 0; x <= rows;x++)
    {
        for(int y = 0;y<=col; y++)
        {
            cout<<USA_map[x][y];
        }
        cout<<endl;
    }
}

//eliminates washington from map
void destroy_sea()
{
    USA_map[2][2] = 'x';
    USA_map[2][3] = 'x';
    USA_map[2][4] = 'x';
}

//eliminates colorado from map
void destroy_den()
{
    USA_map[6][7] = 'x';
    USA_map[6][8] = 'x';
    USA_map[6][9] = 'x';
}

//eliminates georgia from map
void destroy_atl()
{
    USA_map[6][23] = 'x';
    USA_map[6][24] = 'x';
    USA_map[6][25] = 'x';
}
//USA info stop

//USSR info begin
char USSR_map[15][57]=
{
    {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','_','_','-','-','-','_',' '},
    {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','_',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','_','_','_','/',' ',' ',' ',' ',' ',' ','|'},
    {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','_','_','_','/',' ','\\',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','_','_','_','/',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','/'},
    {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','_','/',' ',' ',' ',' ',' ',' ','\\',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','_','/',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|',' '},
    {' ',' ',' ',' ',' ',' ',' ',' ',' ','/',' ',' ',' ','s','p','b',' ',' ',' ','L','_','_','_','_','_','_','_','_','_','_','_','_','_','-','-','-','_','_','-','-',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|',' '},
    {' ',' ',' ',' ',' ','_','_','_','|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','m','a','g','_','/',' ',' '},
    {' ',' ',' ',' ','/',' ',' ',' ',' ',' ','m','o','s',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','_','_','/',' ',' ',' ',' '},
    {' ',' ',' ','|',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*','U','S','S','R','*',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','/',' ',' ',' ',' ',' ',' ',' '},
    {' ',' ',' ',' ','\\',' ',' ',' ',' ',' ',' ','_','_','_',' ',' ',' ','_',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','|',' ',' ',' ',' ',' ',' ',' ',' '},
    {' ',' ',' ',' ',' ','L','_','_','_','_','/',' ',' ',' ','\\','_','/',' ','\\',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','_',' ',' ',' ',' ',' ',' ',' ',' ','|',' ',' ',' ',' ',' ',' ',' ',' ',' '},
    {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','\\',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','/',' ','\\',' ',' ',' ',' ',' ',' ',' ',' ','\\',' ',' ',' ',' ',' ',' ',' ',' '},
    {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','\\',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','/',' ',' ',' ','\\',' ',' ',' ',' ',' ',' ',' ',' ','|',' ',' ',' ',' ',' ',' ',' '},
    {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','_','_','/','\\','_','_','_','_','_','_','-','-',' ',' ',' ',' ',' ','\\','_',' ',' ',' ',' ',' ','|',' ',' ',' ',' ',' ',' ',' ',' '},
    {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','\\',' ',' ','_','/',' ',' ',' ',' ',' ',' ',' ',' ',' '},
    {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','/','_','/',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}
};

/*Ideal USSR map
                                                  __---_
               _                              ___/      |
           ___/ \                         ___/          /
         _/      \                      _/             |
        /         L_____________---__--                |
    ___|                                             _/
  /                                               __/
 |                         USSR                  /
  \      ___   _                                |
   L____/   \_/ \                    _         |
                 \                  / \         \
                  \                /   \         |
                   ---__/\______--      \_      |
                                           \  _/
                                           /_/
 1. Moscow          [6][10],[6][11],[6][12]
 2. St. Petersburg  [4][13],[4][14],[4][15]
 3. Magadan         [5][51],[5][52],[5][53]
 */
//function to show USSR map
void display_USSR()
{
    int rows = 15;
    int col = 57;
    for (int x = 0; x <= rows;x++)
    {
        for(int y = 0;y<=col; y++)
        {
            cout<<USSR_map[x][y];
        }
        cout<<endl;
    }
}

//eliminates Moscow
void destroy_mos()
{
    USSR_map[6][10] = 'x';
    USSR_map[6][11] = 'x';
    USSR_map[6][12] = 'x';
}

//eliminate St. Petersburg
void destroy_spb()
{
    USSR_map[4][13]='x';
    USSR_map[4][14]='x';
    USSR_map[4][15]='x';
}

//eliminate Magadan
void destroy_mag()
{
    USSR_map[5][50]='x';
    USSR_map[5][51]='x';
    USSR_map[5][52]='x';
}

//USSR info end

#endif /* Maps_h */ 
This is the map header file i made. i here is the main.cpp
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#include <iostream>
#include <string>
#include "Maps.h"
#include "Cities.h"

using namespace std;
//intro begining stuff
    Cities Moscow(12000000, 0 , 5,"Moscow");
    Cities St_Petersburg(253693, 0, 5,"St. Petersburg");
    Cities Magadan(151162,0,5,"Magadan");
    Cities Seattle(12000000, 0 , 5,"Seattle");
    Cities Denver(253693, 0, 5,"Denver");
    Cities Atlanta(151162,0,5,"Atlanta");

void wargames()
{
    string introgame = "error";
    while(introgame != "joshua")
    {
    
    cout<<"Password: ";
    cin>>introgame;
        if(introgame == "joshua" || introgame == "Joshua")
        {
            break;
        }
        else
        {
            cout<<"INCORRECT PASSWORD"<<endl;
            cout<<"**** hint \"joshua\" ****"<<endl;
            cout<<"Press enter and try again"<<endl;
            cin.ignore();
            cin.get();
            system("clear");
            //change for windows
        }
    }
}

void gamebegin()
{
    system("clear");
    string yes = "no";
    char game;
    cout<<"Welcome back Mr. Falken, want to play a game?"<<endl;
    while(yes != "yes")
    {
        cin>>yes;
        if(yes == "yes" || yes == "Yes")
        {
            cout<<"What would you like to play?"<<endl;
        }
        else
        {
            cout<<"Please can we play a game Mr. Falken"<<endl;
        }
    }
    cout<<"Falken's games: "<<endl;
    cout<<"[a] <Global Thermonuclear Warfare>"<<endl;
    while (true)
    {
        //cin.ignore();
        cin>>game;
        if(game == 'a' || game == 'A')
        {
            //change for windows
            system("clear");
            cout<<"Launching game...please wait"<<endl;
            cin.ignore();
            cout<<"press 'enter' to begin game..."<<endl;
            cin.get();
            break;
        }
        else
        {
            cout<<"That game isn't in this directory, please choose a valid game"<<endl;
        }
    }
    
}

void manual()//write in later
{
    //fill in later
}

int beginGame()
{
    char user_playas = 'a';
    cout<<"Choose a super-power to play as \n[a] USSR\n[b] USA"<<endl;
    while(true)
    {
        cin>>user_playas;
        if(user_playas == 'a' || user_playas == 'A')
        {
            //ussr = 1
            return 1;
        }
        else if (user_playas == 'b' || user_playas == 'B')
        {
            //usa =0
            return 0;
        }
        else
        {
            cout<<"Not a choice, pick again"<<endl;
        }
    }
}

void USSR_gameplay()
{
    //change for windows version
    system("clear");
    display_USSR();
    cout<<"Cities: "<<endl;
    cout<<Moscow.get_city_name()<<"\t\t\t pop: "<<Moscow.get_total_population()<<endl;
    cout<<St_Petersburg.get_city_name()<<"\t pop: "<<St_Petersburg.get_total_population()<<endl;
    cout<<Magadan.get_city_name()<<"\t\t\t pop: "<<Magadan.get_total_population()<<endl;
    
}

void USA_gameplay()
{
    //change for windows version
    system("clear");

    display_USA();
    cout<<endl;
    cout<<"Cities: ";
    if(Seattle.get_total_population() != 0)
    {
        cout<<"Seatlle";
    }
    if(Denver.get_total_population() != 0)
    {
        cout<<" , Denver";
    }
    if(Atlanta.get_total_population() != 0)
    {
        cout<<" , Atlanta"<<endl;
    }
}



int main()
{
    system("clear");//change for windows
    //wargames();
    //gamebegin();
    if( beginGame() == 1)
    {
        //ussr path
        USSR_gameplay();
    }
    else
    {
        //usa path
        //USA_gameplay();
    }
    
}
everytime i run it i am given this output
**ignore the acsii map**
but it displays "Moscow??" and i can't find anywhere in my code where i want the program to display that, is it a warning of something i'm doing wrong? please help

Choose a super-power to play as
[a] USSR
[b] USA
a

__---_
_ ___/ |
___/ \ ___/ /
_/ \ _/ |
/ spb L_____________---__-- |
___| mag_/
/ mos __/
| *USSR* /
\ ___ _ |
L____/ \_/ \ _ |
\ / \ \
\ / \ |
---__/\______-- \_ |
\ _/
/_/

Moscow??
Cities:
Moscow pop: 12000000
St. Petersburg pop: 253693
Magadan pop: 151162
logout
here is my cities header file and the separate cpp file for defining the methods
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
#include <string>
using namespace std;


#ifndef Cities_h
#define Cities_h


class Cities
{
private:
    int total_population;
    int dead_population;
    int money_generated;
    string city_name;
public:
    //accessor functions to 'return' the private variables
    int get_total_population();
    int get_dead_population();
    int get_money_generated();
    string get_city_name();
    //mutator functions to change the value of the private variables
    void set_total_population(int);
    void set_dead_population(int);
    void set_money_generated(int);
    //default constructor
    Cities();
    //overload constructor
    Cities(int,int,int,string);
    //regular class functions
    void check_population();
};


#endif /* Cities_h */ 


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
64
65
66
67
68
69
70
71
72
73
#include <stdio.h>
#include <iostream>
#include "Cities.h"
using namespace std;

//default constructor and overload constructor
Cities::Cities()
{
    total_population = 0;
    dead_population = 0;
    money_generated = 0;
}

Cities::Cities(int alive,int dead, int money, string name)
{
    total_population = alive;
    dead_population = dead;
    money_generated = money;
    city_name = name;
}


//accessor functions defined
int Cities::get_total_population()
{
    return total_population;
}

int Cities::get_dead_population()
{
    return dead_population;
}

int Cities::get_money_generated()
{
    return money_generated;
}

string Cities::get_city_name()
{
    return city_name;
}


//mutator functions defined
void Cities::set_total_population(int pop)
{
    total_population = pop;
}

void Cities::set_dead_population(int death)
{
    dead_population = death;
}

void Cities::set_money_generated(int income)
{
    money_generated = income;
}

//regular class functions
void Cities::check_population()
{
    if(total_population > 0)
    {
        cout<<city_name;
    }
    else
    {
        Cities(0, dead_population, 0, city_name);
    }
}




my main problem is it displaying "Moscow??" when i run it, nowhere in my code do i want it do this so i am confused and under pressure to finish this. I'm biting off more than i can chew but would like to make this game.
also any helpful and understandable tips about how i should build this would be greatly appreciated
With an array of size x, the valid index numbers are from 0 to x-1. In the display function for the USSR map, you have <= instead of <, so the code is going out of bounds on the array.

char USSR_map[15][57]

1
2
3
4
5
6
7
8
9
10
11
12
13
void display_USSR()
{
    int rows = 15;
    int col = 57;
    for (int x = 0; x <= rows;x++) // x < rows  (rows 0 through 14)
    {
        for(int y = 0;y<=col; y++) // y < col (cols 0 through 56)
        {
            cout<<USSR_map[x][y];
        }
        cout<<endl;
    }
}
thank you so much, you solved it. What i don't get was why it was saying 'moscow??' does it have to do with the object moscow?
Topic archived. No new replies allowed.