AP9_Box.h
1 2 3 4 5 6 7 8 9 | class Box { int width, height; char fill; public: Box(int w, int h) { setSize(w, h); fill = '*'; } void setFill(char f) { fill = f; } void setSize(int w, int h) { width = w; height = h; } void draw(); }; | cs |
AP9_Box.cpp
1 2 3 4 5 6 7 8 9 10 | #include <iostream> #include "AP9_Box.h" using namespace std; void Box::draw() { for (int n = 0; n < height; n++) { for (int m = 0; m < width; m++)cout << fill; cout << endl; } } | cs |
AP9_main.cpp
1 2 3 4 5 6 7 8 9 10 11 12 | #include <iostream> #include "AP9_Box.h" using namespace std; int main() { Box b(10, 2); b.draw(); cout << endl; b.setSize(7, 4); b.setFill('^'); b.draw(); } | cs |
'Programming > 명품 C++ Programming' 카테고리의 다른 글
| 명품 C++ Programming 4장 OpenChallenge (0) | 2018.05.05 |
|---|---|
| 명품 C++ Programming 실습문제 3장 10번 (0) | 2018.04.28 |
| 명품 C++ Programming 실습문제 3장 8-(2)번 (0) | 2018.04.28 |
| 명품 C++ Programming 실습문제 3장 8-(1)번 (0) | 2018.04.28 |
| 명품 C++ Programming 실습문제 3장 7번 (0) | 2018.04.28 |