Thursday, September 19, 2019
c++ - calling template class constructor
Answer
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.
Subscribe to:
Post Comments (Atom)
hard drive - Leaving bad sectors in unformatted partition?
Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...
-
I would like to use the jquery autocomplete function on a field of a form collection. For example, I have a form collection that got those f...
-
My webapp have javascript errors in ios safari private browsing: JavaScript:error undefined QUOTA_EXCEEDED_ERR:DOM Exception 22:An...
-
I needed to resize my Boot Camp partition so I used Gparted to move and resize it. This seemed to work, except that now I can't boot int...
No comments:
Post a Comment