Best alternative for old C ++ function?
Avoid malloc, use a new one.
Avoid memcpy, use a copy constructor.
Avoid #defines
, use const
s.
Avoid (C-style) casts
, use static_cast<C++>( style casts )
.
Avoid macros, use templates.
Avoid post-increment if you can use pre-increment.
Avoid the new ones, use collections of value types, let the collection work with memory management.
Avoid pointers to new objects, use boost::scoped_ptr
orboost::shared_ptr.
Avoid writing your own code to move collections, use <algorithm>
s
Avoid reinventing the wheel, see if boost has what you need.
Avoid "char * name" for storing strings, use std :: string.
Avoid using namespace foo
, use using foo::bar
.
Avoid "static (internal linking) declarations" and use unnamed namespaces.
source to share