so you can see by the code that I made a copy constructor but what I read from my book is that when you make a shallow copy and have a pointer in your class/object both the original and new copy of the class will always point to the same address in memory so I made a deep copy
but when I printed out the address it totally confuses me as it goes against everything I taught in the book the address the pointer points to even though I made a deep copy is still the exact same?
this is really frustraiting does anybody know why the poiters are still pointing to the same address??
ALSO the cout in my copy constructor never actually gets run?
Probably because the copy ctr was elided because of copy elision
Basically, the situation is not as simple as it looks. Does your book discuss move semantics and copy elision? If not, it is probably out of date. C++ is an evolving language, a lot things changed with C++11 :+)
If you avoid using raw pointers and ordinary arrays; use the STL containers instead, then you can avoid lots of these problems. For example toolbox could just be a std::vector
c++ - Deep copy vs Shallow Copy - Stack Overflow
http://stackoverflow.com/questions/2657810/deep-copy-vs-shallow-copy
9.15 — Shallow vs. deep copying « Learn C ++
http://www.learncpp.com/cpp-tutorial/915-shallow-vs-deep-copying/
What is the difference between shallow copy and deep copy in C ++?
https://www.quora.com/What-is-the-difference-between-shallow-copy-and-deep-copy-in-C++
An array in c++ is just a pointer. Memory for an array is allocated on the heap but when you issue an instruction to get the array, you will just get a single integer, just the address in memory where the first item is stored.
As such, when you type up the instructions
int* arrayA = new int[ARRAY_A_SIZE];
int* arrayB = new int[ARRAY_B_SIZE];
//...
arrayA = arrayB;
you've made a terrible mistake.
That's a shallow copy. You've copied the pointer over, and
in my book it said you can just use the assignment operator(=) to call the copy constructor has this changed recently ?
Use of = in an intialization such as: example b = a will result in the copy constructor being called. but outside of that it will be assignment. You may want to re-read a little more carefully.