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;
      public:
              Location();                               
              Location(int lon,int lat);                    
              void view();                              
              Location operator ++();                   
              Location operator --();                   
              void* operator new (size_t size);         
              void   operator   delete( void *   ptr );
              };
              
Location::Location()
                       {
                       l1=0;
                       l2=0;
                       }
 
Location::Location(int lon,int lat)                 
                       {
                       l1=lon;
                       l2=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 ++()
                       {
                       ++l1;
                       ++l2;
                       }

Location Location::operator --()
                       {
                       --l1;
                       --l2;
                       }

void   Location :: operator   delete( void *memory )
                       {
                       cout"Overload delete operator called....."endlendl;
                       free( memory );
                       }


main()
      {
       

system("cls");

                       Location l1(10,20), *l2= new Location(30,40);
                      
                       coutendl"Coordinates for Location 1:";
                       l1.view();
                       ++l1;                                       
                       cout"After applying overloaded ++ operator on Location 1 : ";
                       l1.view();  
                       cout"Coordinates for Location 2:";
                       l2[0].view();             
                       --l2[0];                      
                       cout"After applying overloaded -- operator on Location 2 : ";
                       l2[0].view();          
                       delete l2;
system("pause");

}



Views: 2313

Attachments:

Replies to This Discussion

greet jazakallah

Good Work Brother

well done but one problem occur when it compiled and further continue when press any key. plz make it clear to me. thanx

AOA, bhaai MashaALLAH good work but compilation main error arahay hain please is ko clear kardain.

Thank u so much bhaiya..... but i need ur help to learn c++ its quire difficult 4 me to solve an assignment.i hope u will guide me..

 

now its compile and run fine...

Attachments:

thank u soo much dear................

thanks muzamil

but yah v compile nhi hoo rhi

no need of thanks....if u have any problem with in this file tell me...

thnx broooooooooooooooooo

ye assignment gaalat hai us ne value object k through mange hai laken is me to assignment k through dia hai value

RSS

Looking For Something? Search Below

Latest Activity

saba zulfqar posted a blog post
39 minutes ago
saba zulfqar and Hania Khalid Shariff are now friends
2 hours ago
Muhammad Kasim replied to Sunny's discussion fin622 MCQS needed
3 hours ago
Profile IconMuhammad Kasim and shahzad Hussain joined Virtual University of Pakistan
5 hours ago
Mr Siren Head replied to Hania Khalid Shariff's discussion zero semester
7 hours ago
Hania Khalid Shariff and Huma Ahmad are now friends
17 hours ago
Huma Ahmad liked Hania Khalid Shariff's profile
18 hours ago
BBA(6th smes) left a comment for Rimsha mujahid
19 hours ago

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