calling base class function from derived class object

Solutions on MaxInterview for calling base class function from derived class object by the best coders in the world

showing results for - "calling base class function from derived class object"
Jannik
24 Mar 2017
1#include <iostream>
2#include <string>
3
4using namespace std;
5
6class Person{
7public:
8    void introduce(){
9    cout <<"hey from person"<<endl;
10    }
11};
12
13class Student : public Person{
14public:
15    void introduce(){
16    cout <<"hey from student"<<endl;
17    }
18};
19
20void whosThis(Person &p){
21p.introduce();
22}
23
24int main()
25{
26    Student anil;
27    anil.introduce();
28    whosThis(anil);
29    return 0;
30}
31
32 
queries leading to this page
how can one access a derived class object using base classbase class calling derived class methodscan a base class call derived functioncalling base class function in derived class c 2b 2bcall base class method in derived class c 2b 2bwhen an object of derived class is created does it call base class constructorreturn base class from derived classcall base class method from derived class c 2b 2bhow to call base class function in derived class which overridehow to call a derived class function from base classhow to access base class function using derived class objectfunctio call in base class and derived classbase class object 3d new derived class 3bcalling base class method from derived class in c 2b 2bcan i use method of derived calss by base class objecthow can a derived class call a base class constructorhow to use base class function in derived classcalling base class function from derived class c 2b 2bcall base class method from derived class function c 2b 2bhow to call in base class a derived class object from base class to derived classcall the constructor of base class in derived classscalling base class function from derived class function in c 2b 2bbase class constructor calling from derived classhow to call derived class function from object of base classhow to call base class methods from derived clascall base class function from derived class c 2b 2baccess a method from base or derived class throughhow to access base classs function in derived clascan base class acess derived class methodcall base class function using derived class objectcalling base class function from derived class object in c 2b 2bcalling a base class function from derived class c 2b 2bhow to call derived function from base classcan we call base class function to derived classcalling base class function from derived class object