week4_example_1_cpp file

week4_example_1_cpp file - // second class object cout...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 #include <iostream> #include "rectangle.h" using namespace std int rectangle::howmany = 0 //sets static variable int main() { rectangle r1 // first class object double len = 0.0 double wid = 0.0 cout << "Enter length of rectangle #1: " cin >> len cout << "Enter the width of rectangle #1: " cin >> wid r1.setLength(len) // set length variable of object r1 r1.setWidth(wid) // set width variable of object r1 cout << "Length of r1 = " << r1.getLength() << endl cout << "Width of r1 = " << r1.getWidth() << endl cout << "Area of r1 = " << r1.getArea() << endl cout << "Perimeter of r1 = " << r1.getPerimeter() << endl cout << "Hypoteneuse of r1 = " << r1.getH() << endl c cout << endl << endl cout << "Enter length of rectangle #2: " cin >> len cout << "Enter the width of rectangle #2: " cin >> wid rectangle r2(len, wid)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // second class object cout &lt;&lt; &quot;Length of r2 = &quot; &lt;&lt; r2.getLength() &lt;&lt; endl cout &lt;&lt; &quot;Width of r2 = &quot; &lt;&lt; r2.getWidth() &lt;&lt; endl cout &lt;&lt; &quot;Area of r2 = &quot; &lt;&lt; r2.getArea() &lt;&lt; endl cout &lt;&lt; &quot;Perimeter of r2 = &quot; &lt;&lt; r2.getPerimeter() &lt;&lt; endl cout &lt;&lt; &quot;Hypoteneuse of r2 = &quot; &lt;&lt; r2.getH() &lt;&lt; endl rectangle r3(r2) //calls the copy constructor cout &lt;&lt; &quot;Length of r3 = &quot; &lt;&lt; r3.getLength() &lt;&lt; endl cout &lt;&lt; &quot;Width of r3 = &quot; &lt;&lt; r3.getWidth() &lt;&lt; endl cout &lt;&lt; &quot;Area of r3 = &quot; &lt;&lt; r3.getArea() &lt;&lt; endl Sheet1 Page 2 cout &lt;&lt; &quot;Perimeter of r3 = &quot; &lt;&lt; r3.getPerimeter() &lt;&lt; endl cout &lt;&lt; &quot;Hypoteneuse of r3 = &quot; &lt;&lt; r3.getH() &lt;&lt; endl cout &lt;&lt; endl &lt;&lt; endl cout &lt;&lt; &quot;You have rectangles&quot; &lt;&lt; rectangle::howmany &lt;&lt; endl &lt;&lt; endl system(&quot;pause&quot;) return 0 } Sheet1 Page 3 defalut constructor Sheet1 Page 4...
View Full Document

Page1 / 4

week4_example_1_cpp file - // second class object cout...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online