Tuesday, 26 June 2012

Re: (VU-Study-Corner) CS201 and Cs304 soultion is needed

#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()
{
cout<<endl<<"Longitude : "<<l1<<endl;
cout<<"Latitude : "<<l2<<endl<<endl;
}

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....."<<endl<<endl;
free( memory );
}


main()
{


system("cls");

Location l1(10,20), *l2= new Location(30,40);

cout<<endl<<"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");

}





On Tue, Jun 26, 2012 at 7:40 AM, Me Da bEsT <newheartvoice@gmail.com> wrote:
Hi,
 
Do anyone have CS304 and Cs201 assignment solutions ..???

--
Join us at facebook: https://www.facebook.com/VU.Study.Corner
 
Group Link: http://groups.google.com/group/VU-Study-Corner?hl=en
 
Group Rules: http://groups.google.com/group/VU-Study-Corner/web/group-rules
 
Unsubscribe: VU-Study-Corner+unsubscribe@googlegroups.com
 
Adult contents, Spamming, Immoral & Rudish talk, Cell number, Websites & Groups links specially in paper days are strictly prohibited and banned in group.

--
Join us at facebook: https://www.facebook.com/VU.Study.Corner
 
Group Link: http://groups.google.com/group/VU-Study-Corner?hl=en
 
Group Rules: http://groups.google.com/group/VU-Study-Corner/web/group-rules
 
Unsubscribe: VU-Study-Corner+unsubscribe@googlegroups.com
 
Adult contents, Spamming, Immoral & Rudish talk, Cell number, Websites & Groups links specially in paper days are strictly prohibited and banned in group.

No comments:

Post a Comment