week4_example_1_cpp file

week4_example_1_cpp file - second class object...

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 << "Length of r2 = " << r2.getLength() << endl cout << "Width of r2 = " << r2.getWidth() << endl cout << "Area of r2 = " << r2.getArea() << endl cout << "Perimeter of r2 = " << r2.getPerimeter() << endl cout << "Hypoteneuse of r2 = " << r2.getH() << endl rectangle r3(r2) //calls the copy constructor cout << "Length of r3 = " << r3.getLength() << endl cout << "Width of r3 = " << r3.getWidth() << endl cout << "Area of r3 = " << r3.getArea() << endl Sheet1 Page 2 cout << "Perimeter of r3 = " << r3.getPerimeter() << endl cout << "Hypoteneuse of r3 = " << r3.getH() << endl cout << endl << endl cout << "You have rectangles" << rectangle::howmany << endl << endl system("pause") return 0 } Sheet1 Page 3 defalut constructor Sheet1 Page 4...
View Full Document

Page1 / 4

week4_example_1_cpp file - second class object...

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