I'm getting hard time figuring out solution for calling constructor of class which uses templates.
--Header file
template
class Binary_tree
{
string file_name;
list- arr_data;
public:
Binary_tree(string fname);
void printArr();
};
--cpp file
template
Binary_tree- ::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);
}
}
template
void Binary_tree- ::printArr()
{
int size = arr_data.size();
for (int i = 0; i < size; i++)
{
cout << "arr_data [" << i << "] is: " << arr_data[i] << endl;
}
}
--main.cpp
int main(int argc, char** argv)
{
Binary_tree test(file);
test.printArr();
return 0;
}
Right now I'm getting LNK1120 and LNK2019 errors.
No comments:
Post a Comment