Can we have a non static member function in a base class to
be override in derived with static modifier?

Answer Posted / srinivas

yes we can have a nonstatic membe function in the base ,
which can be override in derived class with static modiier.

for ex:
class sample
{
public:
static void get(){cout<<"this is base class
function:"<<endl;}
static void put(){cout<<"this is a put function of
base class :"<<endl;}
};
class sample1:public sample
{
public:
void put(){cout<<"this is a derived class
function:"<<endl;}
};
sample class is havinfg a non static member function put
which is overidden in dervied which static key word.

Which runs fine.

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the full form of GAC? Explain its uses?

578


What are the differences between static, public and void in c#?

570


Is c# easier than c++?

537


Explain how to implement an object pool in c#.net

526


What framework is used for performance testing/load testing?

1482






What is the use of protected in c#?

497


Why do we need to call CG.SupressFinalize?

556


Can a constructor be static in c#?

523


Is null or empty in c#?

545


How can I produce an assembly?

587


Explain the difference between access specifier and access modifier in c#?

504


Does a class need a constructor c#?

488


What is difference between c and c sharp?

459


What are methods c#?

486


What is reflection in c#?

496