How to create classes with template in C++
I'm trying to create a template class, but some erros has ocurred when i define the methods in the array.cpp file
here are the source code files(i can't post more than 1 hiperlink >.<):
main.cpp: pastebin.com/DxLFDhnc
array.hpp: pastebin.com/MmCAj3Ci
array.cpp: pastebin.com/32czzPBc
errors:
main.cpp undefined reference to `Array::Array(unsigned int)'
main.cpp undefined reference to `Array::operator[](unsigned int)'
main.cpp undefined reference to `Array::operator[](unsigned int)'
main.cpp undefined referen开发者_高级运维ce to `Array::operator[](unsigned int)'
main.cpp undefined reference to `Array::length()'
main.cpp undefined reference to `Array::operator[](unsigned int)'
main.cpp undefined reference to `Array::~Array()'
main.cpp undefined reference to `Array::~Array()'
=== Build finished: 8 errors ===
This should answer your question: http://www.parashift.com/c++-faq-lite/templates.html#faq-35.12
It would help if you posted some code that's giving the error. But from the error messages you're getting, I would say you're class template isn't fully defined in the source unit that instantiates an instance of it. Look at nanothief's link for more info.
精彩评论