//rectangle.h
#include <iostream>
using namespace std;
class rec
{
private:
double width;
double length;
public:
rec(double width, double length);
double calcArea();
};
//rectangle.cpp
#include "rec.h"
rec::rec(double pwidth, double plength)
{
width=pwidth;
length = plength;
}
double rec::calcArea()
{
return width*length;
}
rec::rec(double pwidth, double plength)
{
width=pwidth;
length = plength;
}
double rec::calcArea()
{
return width*length;
}
#include "rec.h"
#include <iostream>
using namespace std;
int main()
{
double a1, a2, tot;
rec rec1(3,4);
rec rec2(5,6);
a1 = rec1.calcArea();
a2 = rec2.calcArea();
tot = a1+a2;
cout << "Total Area is " << tot << endl;
}
#include <iostream>
using namespace std;
int main()
{
double a1, a2, tot;
rec rec1(3,4);
rec rec2(5,6);
a1 = rec1.calcArea();
a2 = rec2.calcArea();
tot = a1+a2;
cout << "Total Area is " << tot << endl;
}
0 comments:
Post a Comment