valgrind valgrind-args progname progam-args
valgrind destructorTest
new and new[]
new calls the constructor.
new[] calls each constructor.
delete and delete[]
new, use delete to match it somewhere.
new[], use delete[] to match it somewhere.
void PrintQueue(QueueT q)
QueueT a; ... QueueT b(a);
ClassT(const ClassT & src);
ClassT(ClassT src);
void CopyList(QueueListT * & head, QueueListT src);
QueueT & QueueT::operator =(const QueueT & src)
a = b = c = d = e; is legal in c/c++
QueueT & QueueT::operator =(const QueueT & src) {
if (this != &src) {
// delete the existing memory
// deep copy any dynamic memory
// shallow copy other fields.
}
return *this;
}
SomeType * a = new SomeType
SomeType * b = a;
delete b;
// what is a pointing at?