This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class CRectangle { | |
int x, y; | |
public: | |
CRectangle(); | |
CRectangle(int _x, int _y); | |
void set_values (int,int); | |
int area () {return (x*y);} | |
}; | |
void CRectangle::set_values (int a, int b) { | |
x = a; | |
y = b; | |
} | |
CRectangle::CRectangle():x(0),y(0) | |
{} | |
CRectangle::CRectangle(int _x, int _y):x(_x),y(_y) | |
{} | |
int main () { | |
CRectangle rect, rectb, rectc(3,4); | |
rectb.set_values (5,6); | |
cout << "rect area: " << rect.area() << endl; | |
cout << "rectb area: " << rectb.area() << endl; | |
cout << "rectc area: " << rectc.area() << endl; | |
return 0; | |
} |
No comments:
Post a Comment