rss
twitter
    Find out what You Want :)
Home    Downloads    Corner    Market    News sites    About Us

Tuesday, February 1

CS201 Assignment#5


CS201 Assignment#5 Solution


#include <iostream.h>
#include<conio.h>
#include<math.h>

class CRectangle
{
int width, height;
public:
void set_values (int, int);
int area (void)
{
return (width * height);
}
};

void CRectangle::set_values (int a, int b)
{
width = a;
height = b;
}

int main ()
{
CRectangle a, *b, *c;
CRectangle * d = new CRectangle[2];
b= new CRectangle;
c= &a;
a.set_values (2,4);
b->set_values (6,8);
d->set_values (10,12);
d[1].set_values (14,16);
cout<<"a area: " <<a.area()<<endl<<endl;
cout<<"*b area: " <<b->area()<<endl<<endl;
cout<<"*c area: " <<c->area()<<endl<<endl;
cout<<"d[0] area: "<<d[0].area()<<endl<<endl;
cout<< "d[1] area: " <<d[1].area()<<endl<<endl;
getch();
return 0;
}
 

No comments:

Post a Comment

Discus Your Study Problems Here

Is This Blog Is Useful For You?

Face Book Fans