Protected Inheritance - Article Pins Online

Mobile Menu

Powered by Blogger.

Text Widget

We Really Pay You. Get Started Free!


Protected Inheritance

 // Online C++ compiler to run C++ program online #include <iostream> using namespace std; class size{     protected:     int length; ...

Contact Us

Name

Email *

Message *

Search This Blog

Page

Top Ads

Responsive Leaderboard Ad Area with adjustable height and width.

More News

logoblog

Protected Inheritance

Saturday, 23 November 2024

 // Online C++ compiler to run C++ program online

#include <iostream>

using namespace std;

class size{

    protected:

    int length;

    

    public:

    

    size(int l=0){

        

        length = l;

    }

    

    void display(){

        cout<< "The length is : " << length;

        

    }

    

}


;


class  vol : public size {

    

    public:

    

    vol(int l):size(l){

        

        

    }

    

    

    void calVol() {

        

     length++;

    }

    

    

    

};

int main() {

    // Write C++ code here

   

    

    vol v(2);

    

    v.calVol();

    

    v.display();

  

    return 0;

}