TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Monday 24 August 2020

Granting Access In C++| Definition Of Granting Access In C++ |Program Of Granting Access In C++ | Granting Access In C++ In Hindi

 

Granting Access In C++

When a base class is inherited as private, all public and protected members of that class become private members of the derived class. However, in certain circumstances, you may want to restore one or more inherited members to their original access specification.

image of Granting Access In C++
Fig: Granting Access In C++


Syntax:

class base class

{

private:

----------

public:

---------

};

class derived: public base class

{

baseclass::member1;

baseclass::member2;

baseclass::function name;

};


Program:

#include<iostream.h>

#include<conio.h>

class base

{

private:

int i;

public:

int j,k;

void set(int x)

{

i=x;

}

int get()

{

return(i);

}

};

class derived: public base

{

public:

base::j;

base::set;

base::get;

int a;

};

void main()

{

derived db;

db.j=20;

db.a=40;

db.set=(10);

cout<<db.get()<<” “<<db.j<<” “<<db.a;

getch();

}


Output:

10   20    40

 

 

No comments:

Post a Comment