Archive for the ‘Tutorials’ Category

Differences between C and C++ – Completed

The keyword typedef
The keyword typedef is in C++ allowed, but no longer necessary when it is used as a prefix in union, struct or enum definitions. This is illustrated in the following example:

struct somestruct
{
int a;
double d;
char string[80];
};

When a struct, union or other compound type is defined, the tag of this type can be used as [...]

Continue Reading..
Posted in Comparisions, Miscellaneous, Tutorials

Overloading ++ and –

Overloading the increment (and decrement) operator creates a slight problem: there are two version of each operator,
as they may be used as postfix operator (e.g., x++) or as prefix operator (e.g., ++x).
Suppose we define a class iterator whose members can be used to visit the elements of an array. The iterator object
will return a pointer [...]

Continue Reading..
Posted in Tutorials, Types, Declarations & Expressions

Overloading operator new(size_t)

If the operator new is overloaded, it must have a void * return type, and at least an argument of type size_t. The size_t
type is defined in stddef.h, which must therefore be included when the operator new is overloaded.
It is also possible to define multiple versions of the operator new, as long as each version [...]

Continue Reading..
Posted in Uncategorized