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

Method Overriding in C++| Method Overriding in C++ Program| Method Overriding in C++ In Hindi

 

Method Overriding in C++

If we inherit a class into the derived class and provide a definition for one of the base class's function again inside the derived class, then that function is said to be overridden, and this mechanism is called Function Overriding.


image of Method Overriding in C++
Fig:Method Overriding in C++

Program:

#include<iostream.h>

#include<conio.h>

void main()

{

class BaseClass()

{

public:

void disp()

{

Cout<<”function of parent class”;

}

};

class  DerivedClass: public BaseClass

{

public:

void disp()

{

cout<<”function of child class”;

}

};

void main()

{

 BaseClass obj=DerivedClass();

obj.disp();

getch();

}

 

Output:

Function of parent class.

No comments:

Post a Comment