Is there any difference btwn C and C++ pointers?Can someone explain to me the use of new and delete operators in C++?Thkx.
Is there any difference btwn C and C++ pointers?Can someone explain to me the use of new and delete operators in C++?Thkx.
Not much difference. They are a variable that holds a memory address. It might be noted that changing the type of a pointer from a derived class to a base class in some cases may also change the value of the pointer (in the case of multiple base classes, for example) -- this is transparent to you as a programmer 99% of the time.
new allocates memory. delete frees it. Example:
new & delete handle the calling of constructors/destructors for classes.Code:std::string *s; s = new std::string(); // use s delete s; s = new std::string[5]; // allocate an array of 5 strings. // use the array delete[] s; // You MUST pair delete[] with new[], and delete with new.
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)