C언어 Rectangle
레이나sv
457 0 0
#include<iostream> using namespace std; class Rectangle { private: int width, height, area; public: Rectangle(int w=5, int h=10) {width=w; height=h;} void setRectangle(int w, int h) {width=w; height=h;} void calcArea(){area=width*height;} int getArea(){return area;} void print(); }; void Rectangle::print() { cout<<"가로 : "<< width << ",세로 : " << height << ",넓이" << area <<endl; } void main() { Rectangle r; r.calcArea(); r.print(); } |