Having issues fixing these issues: 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 LNK1120: 1 unresolved externals F:\Dev103\thermonuclear war game\Debug\thermonuclear war game.exe 1

//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. 



//cpp file

#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.

unresolved external symbol "public: __thiscall grid::grid(void)"

This is saying that you have no implementation of the grid class' constructor.

commented: Thanks +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.