Template definitions belong in headers
#Template definitions belong in headers II suspect your test is also in LinkedList.cpp, yes? This'll prove to be a headache in the future. Definitions as part of a template class need to be available during object file generation, which is only possible if the definition is available in the same translation unit, such as by an included header file.
Prefer modern conventions
#Prefer modern conventions AssumingAssuming you're using a modern compiler, the C++ 11 standard should be the default unless you've (for some reason) specified otherwise. This has implications to your use of pointers.
[Live Example][1]Live Example
As an aside, there are a methods listed in your test code not supported by the posted implementation. In the future, either exclude references to those methods from your example or include the relevant source. [1]: http://cpp.sh/8adh
#Template definitions belong in headers I suspect your test is also in LinkedList.cpp, yes? This'll prove to be a headache in the future. Definitions as part of a template class need to be available during object file generation, which is only possible if the definition is available in the same translation unit, such as by an included header file.
#Prefer modern conventions Assuming you're using a modern compiler, the C++ 11 standard should be the default unless you've (for some reason) specified otherwise. This has implications to your use of pointers.
[Live Example][1]
As an aside, there are a methods listed in your test code not supported by the posted implementation. In the future, either exclude references to those methods from your example or include the relevant source. [1]: http://cpp.sh/8adh
Template definitions belong in headers
I suspect your test is also in LinkedList.cpp, yes? This'll prove to be a headache in the future. Definitions as part of a template class need to be available during object file generation, which is only possible if the definition is available in the same translation unit, such as by an included header file.
Prefer modern conventions
Assuming you're using a modern compiler, the C++ 11 standard should be the default unless you've (for some reason) specified otherwise. This has implications to your use of pointers.
As an aside, there are a methods listed in your test code not supported by the posted implementation. In the future, either exclude references to those methods from your example or include the relevant source.
#Template defintionsdefinitions belong in headers I suspect your test is also in LinkedList.cpp, yes? This'll prove to be a headache in the future. Definitions as part of a template class need to be available during object file generation, which is only possible if the definition is available in the same translation unit, such as by an included header file.
#Template defintions belong in headers I suspect your test is also in LinkedList.cpp, yes? This'll prove to be a headache in the future. Definitions as part of a template class need to be available during object file generation, which is only possible if the definition is available in the same translation unit, such as by an included header file.
#Template definitions belong in headers I suspect your test is also in LinkedList.cpp, yes? This'll prove to be a headache in the future. Definitions as part of a template class need to be available during object file generation, which is only possible if the definition is available in the same translation unit, such as by an included header file.
I#Template defintions belong in headers I suspect your test is also in LinkedList.cpp, yes? This'll prove to be a headache in the future. Definitions as part of a template class need to be available during object file generation, which is only possible if the definition is available in the same translation unit, such as by an included header file.
Assuming#Prefer modern conventions Assuming you're using a modern compiler, the C++ 11 standard should be the default unless you've (for some reason) specified otherwise. This has implications to your use of pointers.
- In modern code, prefer
nullptr
toNULL
. - Prefer smart pointers (such as std::unique_ptr) to raw pointers. This will add a measure of exception-safety to your copy constructor (at some point---for those occassions in the future, that you might use this template for non-primitive types)--- and eliminateeliminates the need to define a custom dtor.
[Live Example][1]
As an aside, there are a methods listed in your test code not supported by the posted implementation. In the future, either exclude references to those methods from your example or include the relevant source. [1]: Live Examplehttp://cpp.sh/8adh
I suspect your test is also in LinkedList.cpp, yes? This'll prove to be a headache in the future. Definitions as part of a template class need to be available during object file generation, which is only possible if the definition is available in the same translation unit, such as by an included header file.
Assuming you're using a modern compiler, the C++ 11 standard should be the default unless you've (for some reason) specified otherwise. This has implications to your use of pointers.
- In modern code, prefer
nullptr
toNULL
. - Prefer smart pointers (such as std::unique_ptr) to raw pointers. This will add a measure of exception-safety to your copy constructor (at some point in the future, you might use this for non-primitive types) and eliminate the need to define a custom dtor.
#Template defintions belong in headers I suspect your test is also in LinkedList.cpp, yes? This'll prove to be a headache in the future. Definitions as part of a template class need to be available during object file generation, which is only possible if the definition is available in the same translation unit, such as by an included header file.
#Prefer modern conventions Assuming you're using a modern compiler, the C++ 11 standard should be the default unless you've (for some reason) specified otherwise. This has implications to your use of pointers.
- In modern code, prefer
nullptr
toNULL
. - Prefer smart pointers (such as std::unique_ptr) to raw pointers. This will add a measure of exception-safety to your copy constructor ---for those occassions in the future that you might use this template for non-primitive types--- and eliminates the need to define a custom dtor.
[Live Example][1]
As an aside, there are a methods listed in your test code not supported by the posted implementation. In the future, either exclude references to those methods from your example or include the relevant source. [1]: http://cpp.sh/8adh