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...
-
Using Windows 7. When I RDP to a PC I'd like to be able to logout of the session without the screen reverting to a Ctrl+Alt+Del Login sc...
-
I tried adding grubx64.efi in the Windows Boot Manager using BCDEdit. However when I boot up my computer and try to start GRUB from Windows ...
-
I have a hp notebook (HP 240 G5 with an Intel Core i3-5005U CPU) with a preinstalled 64 bit Windows 10 Home Single Language. For testing my...
No comments:
Post a Comment