Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

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.

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.

typo
Source Link

#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.

titles and missing methods
Source Link

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 to NULL.
  • 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 to NULL.
  • 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.

Live Example

#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 to NULL.
  • 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

added code
Source Link
Loading
Source Link
Loading
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /