Question: 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.
 private: double x,y,z; l; class 3DShape 1 public: 3DShape (const string&

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!