I think that's the problem. So I'll have to find another way around it.Originally Posted by vart
I think that's the problem. So I'll have to find another way around it.Originally Posted by vart
Spot on, I was just trying to put that into words myselfOriginally Posted by vart
You can't declare something on the stack then expect the code to just know that you've extended it onto the heap when you go and pass it by value :P
Personally I'd declare the list on the heap and pass a pointer. You're just creating overhead by copying everything constantly anyway... I suppose that depends on the purpose behind your program to some extent though.
Create a copy constructor that handles the heap-based allocations you made with new() or keep it all on the heap and pass a pointer around.Originally Posted by hardi
Note that for classes using dynamic memory allocation directly you should always provide copyConstructor and operator =Originally Posted by hardi
If you think you don't need them and don't want to implement - a good practice is to create empty functions for them and make them private.
In this case if you still use one of the above by mistake - compiler will note you
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler