- The namespace
std
is not designed for wholesale importation, see "Why is "using namespace std" considered bad practice? " for more detail.The namespace
std
is not designed for wholesale importation, see "Why is "using namespace std" considered bad practice? " for more detail.You could instead do a
using std::cout;
or better qualify the three use-sites.
You could instead do a using std::cout;
or better qualify the three use-sites.
You don't in any way encapsulate the list and abstract over the list. It's just a bunch of
Node
s. Consider putting it all into aList
owning and managing the whole lot.Trying to
remove()
the root-Node
uncovers a bug. Try to trace it through.pointer != nullptr
is just a long-winded way to writepointer
in a boolean context. Respectively forpointer == nullptr
and!pointer
. Yes, Java needs that, but this is C++.When you
return
from theif
-branch, putting the alternative in anelse
-branch is superfluous.A function for printing an object should allow the caller to specify the stream, and be called
operator<<
.There is no reason to rely on the compiler transforming recursion to iteration, especially as it might not always be able.
this
should rarely be used explicitly.
- The namespace
std
is not designed for wholesale importation, see "Why is "using namespace std" considered bad practice? " for more detail.
You could instead do a using std::cout;
or better qualify the three use-sites.
You don't in any way encapsulate the list and abstract over the list. It's just a bunch of
Node
s. Consider putting it all into aList
owning and managing the whole lot.Trying to
remove()
the root-Node
uncovers a bug. Try to trace it through.pointer != nullptr
is just a long-winded way to writepointer
in a boolean context. Respectively forpointer == nullptr
and!pointer
. Yes, Java needs that, but this is C++.When you
return
from theif
-branch, putting the alternative in anelse
-branch is superfluous.A function for printing an object should allow the caller to specify the stream, and be called
operator<<
.There is no reason to rely on the compiler transforming recursion to iteration, especially as it might not always be able.
this
should rarely be used explicitly.
The namespace
std
is not designed for wholesale importation, see "Why is "using namespace std" considered bad practice? " for more detail.You could instead do a
using std::cout;
or better qualify the three use-sites.You don't in any way encapsulate the list and abstract over the list. It's just a bunch of
Node
s. Consider putting it all into aList
owning and managing the whole lot.Trying to
remove()
the root-Node
uncovers a bug. Try to trace it through.pointer != nullptr
is just a long-winded way to writepointer
in a boolean context. Respectively forpointer == nullptr
and!pointer
. Yes, Java needs that, but this is C++.When you
return
from theif
-branch, putting the alternative in anelse
-branch is superfluous.A function for printing an object should allow the caller to specify the stream, and be called
operator<<
.There is no reason to rely on the compiler transforming recursion to iteration, especially as it might not always be able.
this
should rarely be used explicitly.
The namespace
The namespacestd
is not designed for wholesale importation, see "Why is "using namespace std" considered bad practice? " for more detail.std
is not designed for wholesale importation, see "Why is "using namespace std" considered bad practice? " for more detail.
You could instead do a using std::cout;
or better qualify the three use-sites.
You don't in any way encapsulate the list and abstract over the list. It's just a bunch of
Node
s. Consider putting it all into aList
owning and managing the whole lot.Trying to
remove()
the root-Node
uncovers a bug. Try to trace it through.pointer != nullptr
is just a long-winded way to writepointer
in a boolean context. Respectively forpointer == nullptr
and!pointer
. Yes, Java needs that, but this is C++.When you
return
from theif
-branch, putting the alternative in anelse
-branch is superfluous.A function for printing an object should allow the caller to specify the stream, and be called
operator<<
.There is no reason to rely on the compiler transforming recursion to iteration, especially as it might not always be able.
this
should rarely be used explicitly.
The namespace
std
is not designed for wholesale importation, see "Why is "using namespace std" considered bad practice? " for more detail.You don't in any way encapsulate the list and abstract over the list. It's just a bunch of
Node
s. Consider putting it all into aList
.Trying to
remove()
the root-Node
uncovers a bug. Try to trace it through.pointer != nullptr
is just a long-winded way to writepointer
in a boolean context. Respectively forpointer == nullptr
and!pointer
. Yes, Java needs that, but this is C++.When you
return
from theif
-branch, putting the alternative in anelse
-branch is superfluous.A function for printing an object should allow the caller to specify the stream, and be called
operator<<
.this
should rarely be used explicitly.
- The namespace
std
is not designed for wholesale importation, see "Why is "using namespace std" considered bad practice? " for more detail.
You could instead do a using std::cout;
or better qualify the three use-sites.
You don't in any way encapsulate the list and abstract over the list. It's just a bunch of
Node
s. Consider putting it all into aList
owning and managing the whole lot.Trying to
remove()
the root-Node
uncovers a bug. Try to trace it through.pointer != nullptr
is just a long-winded way to writepointer
in a boolean context. Respectively forpointer == nullptr
and!pointer
. Yes, Java needs that, but this is C++.When you
return
from theif
-branch, putting the alternative in anelse
-branch is superfluous.A function for printing an object should allow the caller to specify the stream, and be called
operator<<
.There is no reason to rely on the compiler transforming recursion to iteration, especially as it might not always be able.
this
should rarely be used explicitly.
The namespace
std
is not designed for wholesale importation, see "Why is "using namespace std" considered bad practice? " for more detail.You don't in any way encapsulate the list and abstract over the list. It's just a bunch of
Node
s. Consider putting it all into aList
.Trying to
remove()
the root-Node
uncovers a bug. Try to trace it through.pointer != nullptr
is just a long-winded way to writepointer
in a boolean context. Respectively forpointer == nullptr
and!pointer
. Yes, Java needs that, but this is C++.When you
return
from theif
-branch, putting the alternative in anelse
-branch is superfluous.A function for printing an object should allow the caller to specify the stream, and be called
operator<<
.this
should rarely be used explicitly.