What are some C++ related idioms, misconceptions, and gotchas that you've learnt from experience?
An example:
class A
{
public:
char s[1024];
char *p;
A::A()
{
p = s;
}
void changeS() const
{
p[0] = 'a';
}
};
Even know changeS is a const member function, it is changing the value of the object. So a cons...
I was making an array of objects, and wanted to run the
constructor for the object on every element of the array to
initialize them like so:
cells = new Cell[cols];
Arrays.fill(cells, new Cell());
But I started to doubt that it did what I wanted and sure
enough Arrays.fill(Object[] o, Object val) doesn't do
what I want it to. Esse...
I was shocked when I read this (from the OpenGL wiki):
glTranslate, glRotate, glScale
Are these hardware accelerated?
No, there are no known GPUs that
execute this. The driver computes the
matrix on the CPU and uploads it to
the GPU.
All the other matrix operations are
done on the CPU as well :
glPushMatrix, ...
From the node.js page
"Almost no function in Node directly performs I/O, so the process never blocks. Because nothing blocks, less-than-expert programmers are able to develop fast systems."
so if a less than expert programmer does something like start an infinite loop in the callback, it doesn't kill the system (eventually)?
or, more ...