// Example using new and delete #include #include using namespace std; int main() { int * a= new int[10]; int * b= new int(89); cout << "*b=" << *b << endl; int * c = new (nothrow) int [1000000000]; // The (nothrow) prevents an exception occurring and the failed message // is almost certain to be displayed, unless you are blessed with a // 64 Bit computer and a ton of RAM. if (!c) { cout << "Failed to allocate memory" << endl; } *(a+5)=9; // Adding 5 to the pointer is the same as indexing an array by [5]. cout << "a[5]=" << *(a+5) << endl; delete [] a; delete b; delete [] c; getchar(); return 0; }