Thursday, August 11, 2005

Some Info on C++

I just learnt some information on C++ which I did not find in many books. So I thought it would be nice to share them. If I am wrong please correct me so that we have the right information for all.
The reason that malloc & free should not be mixed up with new & delete is that the heap management is different in C and C++, which might cause improper use of the memory (such as memory leaks, type safety being lost etc.).
Also that when defining a varaible as below
int &j;
is not valid as this cannot allocate storage. The other way is that
int i;
int &j=i;
is very valid.
Comments solicited.

No comments: