Showing posts with label Derived class. Show all posts
Showing posts with label Derived class. Show all posts

Monday, 14 November 2011

Predict the output or error(s) for the following:

class base

{

public:


void baseFun(){ cout<<"from base"<<endl;}


};

class deri:public base

{

public:


void baseFun(){ cout<< "from derived"<<endl;}


};

void SomeFunc(base *baseObj)

{

baseObj->baseFun();


}

int main()

{

base baseObject;


SomeFunc(&baseObject);


deri deriObject;


SomeFunc(&deriObject);


}

Answer:

from base


from base


Explanation: