Answer to Question #209013 in C++ for Shema

Question #209013

Use the point2D class as base class

to derive a new class called

Point3D(x,y,z). In addition to the

derived variables and functions

(methods) the new class has the

variable z with the functions setZ(z1),

getZ(), MoveRel(Dx,Dy,Dz), print(), and

the constructers point3D(),

point3D(x1,y1,z1,pColor), the destructor

-point3D(). Determine which function

is an override function and which one

is an overloaded function of the base

class.


1
Expert's answer
2021-06-20T18:14:01-0400
#include <iostream>  
using namespace std;  
class point2D{
    protected: 
        int x;
        int y;
    public:  
        void setX(int x) {
            this->x=x;
        }
        void setY(int y) {
            this->y=y;
        }
        int getX(){
            return x;
        }
        int getY(){
            return y;
        }
};  
class point3D:public point2D     
    {    
        private:  
            int z;   
        public:
            point3D(){
                
            }
            void setZ(int z1) {
            z=z1;
            } 
            int getZ(){
                return z;
            }
            void MoveRel(int Dx,int Dy,int Dz){
                x=Dx;
                y=Dy;
                z=Dz;
            }
            void print(){
                cout<<"\nx= "<<x<<endl;
                cout<<"\ny= "<<y<<endl;
                cout<<"\nz= "<<z<<endl;
            }
            point3D(int x1, int y1,int z1,string pColor){
                
            }
            ~point3D(){
                
            }
   };   
int main() {  
 
   return 0;  
} 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS