Answer to Question #268199 in C++ for Amit

Question #268199

Define a class ABC. Derive two classes BBC and KBC from ABC. All the classes contains same


member function name as display(). The base class pointer always holds the derived class objects.

1
Expert's answer
2021-11-18T06:54:42-0500
#include<iostream>
using namespace std;
class ABC{
	public:
		void display(){
			cout<<"In base\n";
		}
};
class BBC: public ABC{
	public:
		void display(){
			cout<<"Welcome";
		}
	
}; 
class KBC: public ABC{
	public:
		void display();
};


int main(){
	ABC *c;
	BBC b;
    c = &b;
    c->display();
}

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