Quote:Original post by d000hg
I commonly allocate memory using new but I don't ever see myself wanting to copy my classes. It's bad from a C++ design view though I guess.
A good saying is "do as the ints do" of course only where that makes sense, value-semantics only make sense for particular types for example the I/O streams are non-copyable there not value types it would make no sense to be able to copy/assign them in anycase.
Quote:Original post by d000hg
My main reasons not to use st::vector for everything is that then I can't use ZeroMemory etc.
Well you should never ever use ZeroMemory or any C memory routines on
non POD-types (Plain old data type, a technical definition in the C++ standard), which most C++ user-defined types are.
Quote:Original post by d000hg
and that it makes the code look ugly with iterators everywhere!
Its something to get use to, using the standard library generic algorithms help more to make code clean, concise, short, less prone to bugs and at all the same time efficient. In anycase you don't have to use iterators when using std::vector, it has overloaded subscript operators.
Quote:Original post by d000hg
If I always use std::vector instead of new, will my class be safe to copy?
Yep because the standard library containers implement
value semantics, therefore correctly does deep copies and assignement. That means the default copy constructor & assignement operators
implicitly defined for your user-defined types will correctly copy/assign too, so you don't need to explicitly define copy constructor or assignement operator if that behaviour is appropriate for your situation, in most cases it is.
As DigitalDelusion points out though, if you store pointers instead you still have to take of this your self, no container or array will do this for you.