AVQ4 - cout << "e =...

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 &lt;&lt; &quot;e = &quot;; e.show(cout); cout &lt;&lt; &quot;\n&quot;; fout &lt;&lt; &quot;e = &quot;; e.show(fout); fout &lt;&lt; &quot;\n&quot;; fout.close(); system(&quot;notepad cylinder.out&quot;); return 0; } point::point(int h, int v){ x = h; y = v; } void point::show(ostream&amp; out){ out &lt;&lt; &quot;( x = &quot; &lt;&lt; x &lt;&lt;&quot;, y = &quot; &lt;&lt; y &lt;&lt; &quot; )&quot;; } circle::circle(const point&amp; p, int r):radius(r),centre(p){ } void circle::show(ostream&amp; out){ out &lt;&lt; &quot;( centre = &quot;; centre.show(out); out &lt;&lt;&quot;, radius = &quot; &lt;&lt; radius &lt;&lt; &quot; )&quot;; } cylinder::cylinder(const circle&amp; c, int t):base(c),height(t){ } void cylinder::show(ostream&amp; out){ out&lt;&lt; &quot;( base = &quot;; base.show(out); out&lt;&lt; &quot;, height = &quot;&lt;&lt; height &lt;&lt; &quot; )&quot;; }...
View Full Document

Page1 / 2

AVQ4 - cout &amp;amp;lt;&amp;amp;lt; &amp;amp;quot;e =...

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