Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

private: double x , y , z ; l; class 3 DShape 1 public: 3 DShape ( const string& color ) : color ( color

private:
double x,y,z;
l;
class 3DShape
1
public:
3DShape (const string& color) : color(color){}
virtual double getVolume() const =0;
protected:
string color;
};
i. Terbitkan satu kelas Sphere daripada kelas 3DShape. Kelas 3DSphere perlu mempunyai satu objek center dengan jenis Point yang mewakili koordinat pusat sfera dan satu member data persendirian radius dengan jenis double.
Derive a class Sphere from the class 3DShape. The class Sphere should have an object center of type Point that represents the coordinate of the center of the sphere and a private data member radius of type double.
(3 markah / marks)
ii. Langkau fungsi getVolume() di bawah kelas Sphere untuk mengira isipadu sfera tersebut.
Override the getVolume () function under the class sphere to calculate the volume of the sphere.
(2 markah / marks)
iii. Tuliskan satu fungsi main () untuk menguji kelas-kelas tersebut. Tetapkan warna sfera sebagai biru, jejari =5.5, pusat sfera pada (0.0,0.0,1.0) dan paparkan isipadu sfera tersebut.
Write a main () function to test the classes. Set the color of the sphere as blue, radius =5.5, center of the sphere at (0.0,0.0,1.0) and display the volume of the sphere.
image text in transcribed

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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

Explain the benefits of a health and wellness strategy

Answered: 1 week ago