1. Program to use pointers for both base and derived classes and call the member functions using the `virtual` keyword.
#include <iostream.h>
#include<conio.h>
class Base {
public:
virtual void show() {
cout << "Base class" << endl;
}
};
class Derived : public Base {
public:
void show() {
cout << "Derived class" << endl;
}
};
int main() {
Base *ptr;
Derived obj;
ptr = &obj; // Pointer to base class pointing to derived class object
ptr->show(); // Calls the derived class's show() function due to virtual keyword
getch();
return 0;
}