Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ LANGUAGE Complete the implementation of the classes circle and cylinder as declared in the program cylinder.cpp. Your output file should look like: p =

C++ LANGUAGE

  1. Complete the implementation of the classes circle and cylinder as declared in the program cylinder.cpp. Your output file should look like:

p = ( x = 1, y = 2 )

c = ( center = ( x = 1, y = 2 ), radius = 5 )

d = ( center = ( x = 3, y = 4 ), radius = 6 )

e = ( base = ( center = ( x = 1, y = 2 ), radius = 5 ), height = 5 )

f = ( base = ( center = ( x = 1, y = 2 ), radius = 6 ), height = 7 )

g = ( base = ( center = ( x = 3, y = 4 ), radius = 6 ), height = 7 )

// File: cylinder.cpp

#include

#include

using namespace std;

class point

{

private:

int x; // horizontal position

int y; // vertical position

public:

point(int h, int v); // constructor for the class point

void show(ostream& out); // show the members of point

};

class circle

{

private:

point center;

int radius;

public:

circle(const point& p, int r);

circle(int h, int v, int r);

void show(ostream& out);

};

class cylinder

{

private:

circle base;

int height;

public:

cylinder(const circle& c, int t);

cylinder(const point& p, int r, int t);

cylinder(int h, int v, int r, 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 << " ";

fout << "p = "; p.show(fout); fout << " ";

circle c(p, r);

cout << "c = "; c.show(cout); cout << " ";

fout << "c = "; c.show(fout); fout << " ";

circle d(h, v, s);

cout << "d = "; d.show(cout); cout << " ";

fout << "d = "; d.show(fout); fout << " ";

cylinder e(c, r);

cout << "e = "; e.show(cout); cout << " ";

fout << "e = "; e.show(fout); fout << " ";

cylinder f(p, s, t);

cout << "f = "; f.show(cout); cout << " ";

fout << "f = "; f.show(fout); fout << " ";

cylinder g(h, v, s, t);

cout << "g = "; g.show(cout); cout << " ";

fout << "g = "; g.show(fout); fout << " ";

return 0;

}

point::point(int h, int v)

{

x = h;

y = v;

}

void point::show(ostream& out)

{

out << "( x = " << x <<", y = " << y << " )";

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions