What are some C++ related idioms, misconceptions, and gotchas that you\'ve learnt from experience?
An example:
class A
{
public:
char s[1024];
cha
Do not fall into the trap of using std::noncopyable
unless needed. Yes, it is useful at a lot of places, and should be used there.
The trap is that one starts writing clone()
function along with making it noncopyable, which implements the same functionality. Instead, you can also use explicit
(link) for the copy constructor instead to prevent accidental copying (and make assignment private, or delete the function in C++0x). clone()
is needed for inherited base classes though.