Write a program such that base class pointer or reference will always access/call the derived
version of the members available in derived class, do not have any access to the base class
members.
#include <iostream>
using namespace std;
class student{
private:
string name;
int regno;
void getData(){
}
void diplayData(){
}
};
class science:private student{
public:
string name = "meshack";
};
class department:private student{
public:
string name = "meshack";
};
int main()
{
student s;
s.getData();
s.displayData();
return 0;
}
Comments
Leave a comment