Wednesday, December 29, 2010

C++ Dynamic Pointers

#include

using namespace std;

int main()
{
//star means its derefrenced
double *myDubPtr = new double;
*myDubPtr = 64;

cout << "*myDubPtr = " << *myDubPtr << endl;
cout << "memAdd = " << myDubPtr << endl;

//delete the memory in the heap, dont use the star, you want to delete the memory address allocation
delete myDubPtr;

return 0;
}

No comments:

Post a Comment