#include <iostream>
using namespace std;

class Base
{
  private:
      int baseval1;
 
  protected:
      int baseval2;

  public:
     int baseval3;

    int getprivate(int x)
    {
        baseval1 = x;
       return baseval1;
    }
   
};

class Derived : private Base
{
public:

int getprotect(int x)
{
    baseval2 =x;
    return baseval2;
}

int getpublic(int x)
{
    baseval3 = x;
    return baseval3;
}

int dergetprivate(int x)
{
    int num = Base::getprivate(x);
    return num;
}
 
};


int main() {

    Derived d;
    cout<< d.dergetprivate(10)<<endl;
    cout<< d.getprotect(20)<<endl;
    cout<< d.getpublic(30)<<endl;
    
    return 0;
}


//it will work for both private and protected

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: