0

I'm getting LNK1120 and LNK2019 Errors on VS 2013 express for Desktop. When I compiled it on g++ command line, it gives error as "undefined reference to Binary_tree::Binary_tree(std::string)".

I got all the includes. Here is my code:

**//Header File:**
template <typename Item>
class Binary_tree
{
    string File_Name;
    list<Item> arr_data;

public:
    Binary_tree(string fname);
    ....//More functions definitions.
};

**//BinaryTree.cpp file**
template <typename Item>
Binary_tree<Item>::Binary_tree(string fname)
{
    File_Name = fname;
    total = 0;
    root = nullptr;

    std::ifstream filestream(fname);
    string line;

    while (!filestream.eof())
    {
        filestream >> line;
        arr_data.push_back(line);
    }
}

**//Main.cpp File:**
int main(int argc, char** argv)
{
    string file = "HeapQuestions.txt";
    Binary_tree<string> test(file);

    test.printArr();

    return 0;
}
Gaurav
  • 31
  • 1
  • 5

0 Answers0