AVQ4 - cout<<"e =" e.show(cout...

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

View Full Document Right Arrow Icon
#include <iostream> #include <fstream> #include <string> using namespace std; class point { private: int x; int y; public: point(int h, int v); void show(ostream& out); }; class circle { private: point centre; int radius; public: circle(const point& p, int r); void show(ostream& out); }; class cylinder { private: circle base; int height; public: cylinder(const circle& c, int t); void show(ostream& out); }; int main() { int h = 3, v = 4, r = 5, s = 6, t = 7; ofstream fout("cylinder.out"); point p(1, 2); cout << "p = "; p.show(cout); cout << "\n"; fout << "p = "; p.show(fout); fout << "\n"; circle c(p, r); cout << "c = "; c.show(cout); cout << "\n"; fout << "c = "; c.show(fout); fout << "\n"; cylinder e(c, r);
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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout << "e = "; e.show(cout); cout << "\n"; fout << "e = "; e.show(fout); fout << "\n"; fout.close(); system("notepad cylinder.out"); return 0; } point::point(int h, int v){ x = h; y = v; } void point::show(ostream& out){ out << "( x = " << x <<", y = " << y << " )"; } circle::circle(const point& p, int r):radius(r),centre(p){ } void circle::show(ostream& out){ out << "( centre = "; centre.show(out); out <<", radius = " << radius << " )"; } cylinder::cylinder(const circle& c, int t):base(c),height(t){ } void cylinder::show(ostream& out){ out<< "( base = "; base.show(out); out<< ", height = "<< height << " )"; }...
View Full Document

This note was uploaded on 02/21/2010 for the course ENGM 2282 taught by Professor Phillips during the Winter '10 term at Dalhousie.

Page1 / 2

AVQ4 - cout<<"e =" e.show(cout...

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

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