CDDS
cdds's Introduction
cdds's People
cdds's Issues
Copy assignment operator should clean up/overwrite existing data
Lines 129 to 138 in 4294dc4
Since a list being assigned to may already have existing nodes, you should take care to them up first before overwriting the head
and tail
variable on the list with new nodes duplicated from the other list.
Potential deference of null pointer in binary tree dtor and clear
Lines 86 to 92 in dc470d1
root
is initialized to nullptr
on construction, which is proper and valid behavior. However, the destructor always deferences root
, which can be null if no nodes were added/all nodes were removed.
Deferencing a null pointer is UB; it crashes with MSVC14.
Repro w/ the following code:
#include "tBinaryTree.h"
int main()
{
// construct val in a new "scope"
{
tBinaryTree<int> val;
}
// val will be destroyed before moving past this point
return 0;
}
Potentially undefined use of NULL
Lines 12 to 13 in 4294dc4
Use of NULL
is serviceable, but nullptr
is preferred for coursework. Additionally, this header alone does not define NULL
so use of this may result in compilation errors since NULL
may go undefined as a macro or identifier. While nullptr
is again preferred, other options include...
- defining the
NULL
macro yourself at the top#define NULL 0
- including
#include <cstddef>
at the top which defines NULL (see cppref) - using
nullptr
, a keyword providing a pointer literal for a null pointer ๐ (see cppref)
The use of nullptr
is preferred in contexts like UE4 and also avoids any problems that may stem from accidentally providing a pointer where a numerical value is expected.
Pre-operators should return references to the iterators being incremented
Lines 44 to 48 in 4294dc4
Lines 55 to 59 in 4294dc4
The implementations for your pre-inc/pre-dec operators should return references. As they are now, they are only returning copies of themselves.
To make this change, alter the return type of those operators such that they return iterator &
where the &
denotes that the return type will be a reference rather than a plain value type.
A more idiomatic way of writing !=
Lines 36 to 39 in 4294dc4
This does work! You may want to rewrite instead as...
return !(*this == rhs);
.. which may be more idiomatic.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.