I am writing a code that creates a class rectangle. The class rectangle consists of two member data height and width both of type float. The class rectangle has two member functions getdata() and areacal(). The getdata() function is used to read data in height and width. The areacal() function is used to calculate and display the area of a triangle on the screen. The program creates an array on five (5) objects of the class rectangle using new operator and place the address of the array in a pointer ptr. The type of ptr is rectangle. Now the program reads data into each object and calculates the area using the member functions.

#include <iostream>
class Rectangle {
float width, height, area;
void getdata (float, float);
//float area (void) {return (width * height);
void areacal (float);

void Rectangle::getdata (float a, float b) {
width = a;
height = b;
void Rectangle::areacal (float area) {
area = width * height;
int main () {
char temp;
Rectangle a, *b, *c;
Rectangle * ptr = new Rectangle[2];
b= new Rectangle;
c= &a;
a.getdata (1,2);
b->getdata (3,4);
ptr->getdata (5,6);
ptr[1].getdata (7,8);
cout << "a area: " << a.areacal(a,b) << endl;
cout << "*b area: " << b->areacal() << endl;
cout << "*c area: " << c->areacal() << endl;
cout << "d[0] area: " << ptr[0].areacal() << endl;
cout << "d[1] area: " << ptr[1].areacal() << endl;
cin >> temp;
return 0;