Monday, June 12, 2006

small C++ things to remember

C++ like any other language has small stuff to remember.
since i dont have a good memory, i will keep here short C++ things to remember

2 comments:

Andrei Nitescu said...

the size of an empty class or structure is not zero. it is one.

http://tinf2.vub.ac.be/~dvermeir/c++/emptyopt.html

Andrei Nitescu said...

The base class from which each class is derived is declared before the declaration of the derived class. It is not sufficient to provide a forward-referencing declaration for a base class; it must be a complete declaration.

for example:

class A; // forward declaration


// compile error; A must be defined
class B : public A
{

};

class A
{
};