Question: CSC 2 4 0 C + + classes and inheritance Type in the following C + + program into a file classes.cpp / BASE CLASS

CSC240 C++ classes and inheritance
Type in the following C++ program into a file classes.cpp/BASE CLASS*****************************class A{protected:int x;public:A(){ x =0;}void increment(){ x++; }virtual void decrement(){ x--; }};void print(){ cout "x =" x endl; }/DERIVED CLASS***********************/class B : public A|public:void increment(){ x = x +2; }};void decrement(){ x = x -2; }/MAIN FUNCTION*************************/int main(){A a; // a is an object of class AA * ptr; // ptr is a pointer to an object of class Aptr = &a;ptr -> increment();ptr -> print();ptr -> decrement();ptr -> print();)
CSC 2 4 0 C + + classes and inheritance Type in

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 Programming Questions!