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 read the following instructions carefully before submitting assignment.

It should be clear that your assignment will not get any credit if:


§         The assignment is submitted after due date.

§         The submitted assignment does not open or file is corrupt.

§         Assignment is copied(partial or full) from any source (websites, forums, students, etc)


Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted and will be awarded with zero marks. For example, if you submit code in .doc (Word document) or .txt files, no reward will be given in any case.





The objective of this assignment is to provide hands on experience of:


§         Objects and Classes

§         Constructors and Destructors in classes

§         Setters and Getters in classes

§         Use of friend functions

§         Operator overloading





§         Code should be properly indented and well commented.

§         Follow C/C++ rules while writing variable names, function names etc

§         Use only dev-C++ for this assignment.















Problem Statement:     You are required to write a program for calculating area of Trapezoid. Formula for calculating area of trapezoid is


Where a and b are two bases of trapezoid and h corresponds to height.



Detailed Description:


  • Create a class named Trapezoid which contains two bases and height as data members.
  • Implement a default constructor to initialize all data members with zero and a parameterized constructor which takes three arguments to initialize data members of class.
  • Take input from user for base1, base2 and height of 2 objects.
  • Overload + operator for the class Trapezoid in such a way that corresponding elements of both objects of the same class can be added.
  • Also implement a friend function named calculateArea() which takes two objects of the class Trapezoid as arguments, adds both objects using overloaded + operator and calculates the area of resultant Trapezoid object.






Sample output:


Views: 3822


Replies to This Discussion


#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;

ye to compile hi nhi ho rhi is me to err hai jnab

ye compile hona b nahi hai.. q k ye relevent asnwer hai he nahi..

itx nt my solution

teel the correct program

ye solution C++ mai kis tara likaingai

ye file c++ mai kis tara hoga convert ka tarika batai

Suspense ended! 

Tell to your Friends..



thnks koi error nehi is main

Solution uploaded...


error hain is main b


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

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