Function overriding in C++ (basics)

 #include <iostream>

#include <string>

using namespace std;

class student{

      public:

      void displaystu(){

            cout<<"Hi! My name is Vaibhav Yadav and I'm from ECE Department, First Year' 25"<<endl;

      }

};

class update: public student{

      public:

      void displaystu(){

            student::displaystu();

            cout<<"Details UPDATED"<<endl<<"Hi! My name is Vaibhav Yadav and I'm from 'IT' Department, First Year' 25"<<endl;

      }

};

int main()

{

    update up;

    up.displaystu();

    return 0;

}


No comments:

Post a Comment

Operator Overloading in C++

#include<iostream> using namespace std; class Complex { private: int real, imag; public: Complex(int r = 0, int i = 0){       re...