1

In the following code a public function has overriden a private virtual function in base class ob->hello() shall call hello() in derived class which is public. why do i still see an error that hello() is private.

    ```
     #include<iostream>
     using namespace std;

     class base{
       private:
       virtual void hello();
     };

     class der: public base{
        public:
        void hello();
      }; 

      void der::hello(){
        cout<<"hi"<<endl;
      }    

      void base::hello(){
        cout<<"hello"<<endl;
      }

      int main(){
         base* ob = new der();
         ob->hello();
      }    
      ```

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.