I'm trying to make a pointer call the copy constructor on creation but keep referencing the object instead it seems. Is what I'm doing completely wrong then.
Queue<int> * a = new Queue<int>();
Queue<int> * b = a;
This keeps referring to a instead of using the copy constructor which works fine on stack allocated objects.
You can't call copy constructors through pointers like that.
To call the copy constructor you need to be more explicit:
Queue< int >* b = new Queue< int >( *a );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With