File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ class rectangle_t {
5050 }
5151
5252 void convert (const square_t & sq) noexcept ;
53+
54+ friend std::ostream& operator <<(std::ostream& os, const rectangle_t & rect);
5355};
5456
5557class square_t {
@@ -79,19 +81,28 @@ void rectangle_t::convert(const square_t& sq) noexcept {
7981 height = sq.side ;
8082}
8183
84+ std::ostream& operator <<(std::ostream& os, const rectangle_t & rect) {
85+ os << rect.width << " x " << rect.height ;
86+ return os;
87+ }
88+
8289int main () {
8390 rectangle_t r1;
8491 rectangle_t r2 (2 , 3 );
8592
93+ std::cout << " Original rectangle: " << r2 << std::endl;
94+
8695 r1 = double_in_size (r2);
8796
97+ std::cout << __LINE__ << " : " << r1 << std::endl;
8898 std::cout << r1.area () << std::endl;
8999
90100 rectangle_t rect;
91101 square_t sqr (4 );
92102
93103 rect.convert (sqr);
94104
105+ std::cout << __LINE__ << " : " << rect << std::endl;
95106 std::cout << __LINE__ << " : " << rect.area () << std::endl;
96107
97108 return 0 ;
You can’t perform that action at this time.
0 commit comments