Overloaded functions

Hi,
I had posted a question some days back. I have refined my question a little    bit.
Please consider a class

class Base{
...
virtual fnSomefunction(int)=0;
}

class DER : public Base{
fnSomefunction(int);
fnSomefunction(int,int);
}

When I try to compile the above, I get an error.

\Test1.cpp(46) : error C2259: 'Base' : cannot instantiate abstract class due to following members:
Test1.cpp(4) : see declaration of 'Base'

Why cant I overload a pure virtual

function in a derived class?

Regards

Shayad.
shayadAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

inprasCommented:
Hi shayad
U can overload the pure virtual function but a class with one or more pure virtual functions cannot be instantiated. Each pure virtual function must be overridden in a derived class before objects of the derived class can be instantiated.
So U cant vave an object defined of call Base. U can how ever create the objects of class DER
check this
#include<iostream.h>
class Base
{
public:
      virtual fnSomefunction(int)=0;
} ;

class DER : public Base
{
public:
      fnSomefunction(int)
      {
            return 1;
      }
      fnSomefunction(int,int)
      {
            return 2;
      }
} ;
void main(void)
{
      DER d;
      Base b;//This Gives an error
}
Regards

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
freshmeatCommented:
try this:

class Base{
....
virtual fnSomefunction(int)=0;
}

class DER : public Base{
 virtual fnSomefunction(int);
 virtual fnSomefunction(int,int);
}

BTW, in last question, i gave u the right answer, but the points r given to another guy who said some useless words...
:((((((((((

anyway, good luck to try my code
:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.