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.

Please discuss about the assignment!


Problem Statement:     Location Calculation     


You are required to write a program for calculating location somewhere on the map. There are two parameters (coordinates) used in calculating a location. One is longitude and the other is latitude. You need to overload ++, --, new and delete operators for this.


Detailed Description:


  • You are required to create a class named Location.
  • It will have two private data member longitude and latitude.
  • These data members will be assigned values through constructor parameters. For example obj1(20,30).
  • Overloaded ++ operator will increase the both longitude and latitude values by one, overloaded -- will decrease both by one.
  • By overloading new operator, you will allocate the memory dynamically for the object of class Location.
  • The overloaded delete operator will free (de-allocate) the allocated memory.
  • You have to create two objects of class Location. One object will be created through overloaded new operator and other will be created without it.
  • A message “Overloaded new operator called”, embedded inside overloading function for new operator, should be displayed when the object is created through new operator.
  • Similarly, a message “Overload delete operator called” should be displayed upon calling overloaded function of delete operator.
  • Assign the values (10, 20) and (30, 40) for longitude and latitude for object 1 and 2 respectively.

Views: 5598


Replies to This Discussion

include <iostream.h>
using namespace std;

class location
int longitude;
int latitude;
location(int j,int i);
void display();
void* operator new (size_t size);
location operator ++();
location operator --();

location::location(int j,int i)

void location::display()
cout" Longitude : " endl;
cout" Latitude : " endl;

void* location::operator new(size_t size)
cout" Overloaded New operator Called" endl; 
void *pointer=malloc(size);
return pointer;

location location::operator ++()

location location::operator --()

location *loc,l2;
loc=new location(10,20);
cout" After calling Overloaded ++ operator on location 1" endl;
cout"Coordinate for location 2 :"endl;
cout" After calling Overloaded -- operator" endl;
system ("pause");
delete loc,l2;

yea wala sol kaharab hea ok.

tehreem ji thora sa kam he krny wala hai ..baki tu ye program fit hai ..wots wrong with it?

kon sa kam btaoo na

Yar afsoos hai chalo hint de deta hoon wo aik character in main se aik hai
1- ""
2- ;
3- :

Ap aik dfa he sol kyun nai snd kr daitay???

hahahah...good point dear..

bta dun main inhy ??

bta dian gay to sb ki dua milay gi. warna kisi nay apko kia kahna ha????

Dear Plz share complete solution..

@yasir saleem......ur code is executing  but its not giving correct values with ++operator...plz comment...???

thnx for the solution

I leave it intentionally because of Waqas comment

Yar KHUDA da naam ay, pahailian na bhujwao solution upload kr deo ALLAH tohanu ays di jaza dayway, specially for you my brother yasir saleem 

@yasir...............wat does this mean(location *loc,l2)???can't inderstand  and how can we write in the code  for location 1 and location 2 except the method u have given????as in the output we have to call location 1 and location 2 coordinares (coordinates for location 1 and coordinates for location 2 called) plz...


Looking For Something? Search Below

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