Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

#Memory Management#

Memory Management

If you don't have any special reason for using raw pointers, smart pointer can save you from a lot of headaches.

#Passing Paramters#

Passing Paramters

Passing non-trivial parameters (like std::vector) by value degrades performance.

#API#

API

Except for some homework assignments, one never uses a tree simply for printing values to the console. Your traverse methods should provide a way to iterate over the elements and do anything with each element.

A standard approach would be to provide iterators, but you could at least accept a callback and simply invoke it as you're traversing the elements.

If you're not exposing any public method that takes or returns a Node, I would hide the structure, it as an implementation detail.

#Memory Management#

If you don't have any special reason for using raw pointers, smart pointer can save you from a lot of headaches.

#Passing Paramters#

Passing non-trivial parameters (like std::vector) by value degrades performance.

#API#

Except for some homework assignments, one never uses a tree simply for printing values to the console. Your traverse methods should provide a way to iterate over the elements and do anything with each element.

A standard approach would be to provide iterators, but you could at least accept a callback and simply invoke it as you're traversing the elements.

If you're not exposing any public method that takes or returns a Node, I would hide the structure, it as an implementation detail.

Memory Management

If you don't have any special reason for using raw pointers, smart pointer can save you from a lot of headaches.

Passing Paramters

Passing non-trivial parameters (like std::vector) by value degrades performance.

API

Except for some homework assignments, one never uses a tree simply for printing values to the console. Your traverse methods should provide a way to iterate over the elements and do anything with each element.

A standard approach would be to provide iterators, but you could at least accept a callback and simply invoke it as you're traversing the elements.

If you're not exposing any public method that takes or returns a Node, I would hide the structure, it as an implementation detail.

added 1 character in body
Source Link
D. Jurcau
  • 3.1k
  • 13
  • 21

#Memory Management#

If you don't have any special reason for using raw pointers, smart pointer can save you from a lot of headaches.

#Passing Paramters#

Passing non-trivial parameters (like std::vector) by value degrades performance.

#API#

Except for some homework assignments, one never uses a tree simply for printing values to the console. Your traverse methods should provide a way to iterate over the elements and do anything with each element.

A standard approach would be to provide iterators, but you could at least accept a callback and simply invoke it as you're traversing the elements.

If you're not exposing any public method that takes or returns a Node, I would hide the structure, it as an implementation detail.

#Memory Management#

If you don't have any special reason for using raw pointers, smart pointer can save you from a lot of headaches.

#Passing Paramters#

Passing non-trivial parameters (like std::vector) by value degrades performance.

#API#

Except for some homework assignments, one never uses a tree simply for printing values to the console. Your traverse methods should provide a way to iterate over the elements and do anything with each element.

A standard approach would be to provide iterators, but you could at least accept a callback and simply invoke it as you're traversing the elements.

If you're not exposing any public method that takes or returns a Node, I would hide the structure it as an implementation detail.

#Memory Management#

If you don't have any special reason for using raw pointers, smart pointer can save you from a lot of headaches.

#Passing Paramters#

Passing non-trivial parameters (like std::vector) by value degrades performance.

#API#

Except for some homework assignments, one never uses a tree simply for printing values to the console. Your traverse methods should provide a way to iterate over the elements and do anything with each element.

A standard approach would be to provide iterators, but you could at least accept a callback and simply invoke it as you're traversing the elements.

If you're not exposing any public method that takes or returns a Node, I would hide the structure, it as an implementation detail.

Source Link
D. Jurcau
  • 3.1k
  • 13
  • 21

#Memory Management#

If you don't have any special reason for using raw pointers, smart pointer can save you from a lot of headaches.

#Passing Paramters#

Passing non-trivial parameters (like std::vector) by value degrades performance.

#API#

Except for some homework assignments, one never uses a tree simply for printing values to the console. Your traverse methods should provide a way to iterate over the elements and do anything with each element.

A standard approach would be to provide iterators, but you could at least accept a callback and simply invoke it as you're traversing the elements.

If you're not exposing any public method that takes or returns a Node, I would hide the structure it as an implementation detail.

lang-cpp

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