tags:

views:

44

answers:

1

Here the code

    #include <iostream>
    #include <conio.h>

    using namespace std;

    template <typename T> class grid
    {
    public:
        grid();
        ~grid();
        void createCells();
    private:
        T **cells;
    };

 int main(int argc, char **argv)
    {
        grid<int> intGrid;
        _getch();
        return 0;
    }

While trying to compile - got a message:

1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall
grid<int>::~grid<int>(void)" (??1?$grid@H@@QAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall 
grid<int>::grid<int>(void)" (??0?$grid@H@@QAE@XZ) referenced in function _main

What need to do?

+1  A: 

You need to define the constructor and destructor (you just declared them):

template <typename T> class grid
{
public:
    grid()
    {}    // here
    ~grid()
    {}    // and here
    void createCells();
private:
    T **cells;
};
R Samuel Klatchko
Thanks, compiled!
zed91