Accessing the Overridden Methods in C++ | Cpp

  c++

Email

#include<iostream>

using namespace std;

class Father{

public :

void setname()
{
cout << “this aniln”;
}
};

class Mother : public Father{

public :
void setname()
{

cout << “n this codoingof the”;
Father::setname();
}

};

int main()
{

Mother naik;
naik.setname();

return 0;

}

Spread the Code

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of