Creating a Stray Pointer : pointer « Data Type « C++






Creating a Stray Pointer

  
typedef unsigned short int USHORT;
#include <iostream>

int main()
{
   USHORT * pInt = new USHORT;
   *pInt = 10;
   std::cout << "*pInt: " << *pInt << std::endl;
   delete pInt;

   long * pLong = new long;
   *pLong = 90000;
   std::cout << "*pLong: " << *pLong << std::endl;

   *pInt = 20;      

   std::cout << "*pInt: " << *pInt  << std::endl;
   std::cout << "*pLong: " << *pLong  << std::endl;
   delete pLong;
   return 0;
}
  
    
  








Related examples in the same category

1.Returning Values with Pointers
2.Passing Pointer to a Constant Object
3.Demonstrating Passing by Value