//Program in cpp to demonstrate inheritance, inh2.cpp
#include<iostream>
using namespace std;
class base
{
private:
void prifun()
{
cout<<"\n private Function";
}
public:
void pubfun()
{
cout<<"\n public Function";
}
protected:
void profun()
{
cout<<"\n protected Function";
}
};
class derived:protected base
{
public:
void fun()
{
//prifun();
pubfun();
profun();
}
};
int main()
{
base b;
derived d;
//b.prifun();
b.pubfun();
//b.profun();
//d.prifun();
//d.pubfun();
//d.profun();
d.fun();
return 0;
}
No comments:
Post a Comment