How to fix unresolved external symbol issue?

Having issues fixing these issues:Error 2 error LNK2019: unresolved external symbol "public: __thiscall grid::grid(void)" (??0grid@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for 'GridObject''(void)" (??__EGridObject@@YAXXZ) F:\Dev103\thermonuclear war game\thermonuclear war game\Grid.obj


Error 3 error LNK1120: 1 unresolved externals F:\Dev103\thermonuclear war game\Debug\thermonuclear war game.exe 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//header file
#include <iostream>
using namespace std;
class grid{

	int r, c;

public:
	grid();
	void GridFunction();
	int getR(){return r;}
	int getC(){return c;}
	void setR(int a){a = r;}
	void setC(int b){b = c;}

};
//create object
extern grid GridObject; //has something to do with this, when commented out fixes that error but rest of my program has issues. 


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
#include <iostream>
#include "Grid.h"
#include "Cities.h"

using namespace std;

grid GridObject;//has something to do with this

void grid::GridFunction(){
	
	//randomly generate grid size
	//set rows
	GridObject.setR(rand()%16+7);
	//set columns
	GridObject.setC(rand()%16+7);

	//display x co-ordinates
	for(int i=0;i <=GridObject.getC(); i++){
	
		cout << "  " << i << "  ";
	}

	int counter = 0;
	for(int s=1;s< GridObject.getC()*GridObject.getR();s++){

		cout << "+--+";


		if(!(s % GridObject.getC())){
			
			cout << endl;
				
				for(int s=0;s<GridObject.getC();s++){

					
					cout << "| << CityObject.getX() CityObject.getY()<< |";
				}
		}
		if(!(s%GridObject.getC())){
		//generate x co-ordinates
		counter++;
		cout <<" "<<counter;
		cout << endl;
		}
	}

}

It has more to the program but the error is in this part. Any help will be highly appreciated.
Try not creating the object in the header
That wasn't the issue. Found out of someone else. I had made the grid constructor but had not given the definition in the .cpp file.
Topic archived. No new replies allowed.