C++

#include <cstdlib>
#include <iostream>
using namespace std;
class CSquare;
class CRectangle{
int width, height;
public:
int area(){return (width * height);}
void convert (CSquare a);
};
class CSquare{
private:
int side;
public:
void set_side(int a){side=a;}
friend class CRectangle;
};
int main()
{
CSquare sqr;
CRectangle rect;
sqr.set_side(4);
rect.convert(sqr);
cout <<endl<<rect.area()<<endl;
system(“PAUSE”);
return EXIT_SUCCESS;

}
void CRectangle::convert(CSquare a){
width=a.side;
height=a.side;
}

Komentar

Postingan populer dari blog ini

MAKHLUK HIDUP DALAM EKOSISTEM ALAMI

ASYNCRONOUS