Location(int lon,int lat);
Location operator ++();
Location operator --();
void* operator new (size_t size);
void operator delete( void * ptr );
Location::Location(int lon,int lat)
coutendl"Longitude : "l1endl;
cout"Latitude : "l2endlendl;
void* Location::operator new(size_t size)
cout"Overloaded new operator called....." endl;
void * rtn = malloc (size ) ;
Location Location::operator ++()
Location Location::operator --()
void Location :: operator delete( void *memory )
cout"Overload delete operator called....."endlendl;
free( memory );
Location l1(10,20), *l2= new Location(30,40);
coutendl"Coordinates for Location 1:";
cout"After applying overloaded ++ operator on Location 1 : ";
cout"Coordinates for Location 2:";
cout"After applying overloaded -- operator on Location 2 : ";
object k through he hai dear..more clarify me ur point ..
but muzamil yah compail ni ho rhi
there is not wrong with this file ..go to first discussion about this assignment u will get the whole idea..
Brother! what the heck "malloc" is? where you did declare this?
malloc and calloc function for allocating a memory ..in this assignment u havce to overload new operator coz object always can allocate the memory by new operator in dynamically..so u have to defined a malloc or calloc function to allocate memory in the definition of overloading new operator ..okay ?
similarly when we are allocating memory by malloc or calloc functions then its our responsibility to free the memory allocated... so u have to overload delete operator for it..
can u plz tell k press enter to continue likhne k liye kon sa code use hota hai aur kahan pe??
thanks a lot
complte and 100% correct