Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

#include <iostream.h>

class Location
              int l1;
              int l2;
              Location(int lon,int lat);                    
              void view();                              
              Location operator ++();                   
              Location operator --();                   
              void* operator new (size_t size);         
              void   operator   delete( void *   ptr );
Location::Location(int lon,int lat)                 

void Location::view()
                       coutendl"Longitude : "l1endl;
                       cout"Latitude : "l2endlendl;

void* Location::operator new(size_t size)
                       cout"Overloaded new operator called....." endl;  
                       void *   rtn   = malloc (size ) ;
                       return   rtn;    

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 : ";
                       delete l2;


Views: 2313


Replies to This Discussion

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 this assignment u havce to overload new operator coz object always can allocate the memory by new operator in 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 brther!

thanks a lot

complte and 100% correct



Looking For Something? Search Below

Latest Activity

Ziddi Programmer commented on + M.Tariq Malik's page Chit Chat Wall
4 hours ago
Ziddi Programmer replied to Mr Siren Head's discussion Ning Chats
5 hours ago
Ziddi Programmer liked Mr Siren Head's discussion Ning Chats
5 hours ago
Mr Siren Head replied to + !♛EMAN FATIMA!'s discussion Course Selection
5 hours ago
mumtaz Muddasir Yasin is now a member of Virtual University of Pakistan
6 hours ago
Saeed liked Mehreen Tasneem's profile
Mehak commented on + M.Tariq Malik's page VULMS Login Here
Mr Siren Head replied to Mr Siren Head's discussion Ning Chats

VIP Member Badge & Others

How to Get This Badge at Your Profile DP


Management: Admins ::: Moderators

Other Awards Badges List Moderators Group

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service