Problem with Inheritance in c++

I have a function under Base class and at the definition tine of this base class function I need to call another function which is define under the Derived class. how to do this??
My class declaration is below
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Base{

public:

void showdata(double);

};

class Derived : public Base{

public:
	inline double F(double x)
{
	return exp(-x) + x*x;
}


Define the function below :

1
2
3
4
void Base::showdata(double a)
{
	std::cout<<"The value of the Function : " << F(a);
}


and the main function :
1
2
3
4
5
6
int main()
{
Derived obj;
obj.F(1.0);
return 0;
}


I'm getting an error :
error C3861: 'F': identifier not found

So how to solve this problem.
Warm Regards
sdmahapatra
You have to declare F as a (pure) virtual function in Base.

1
2
3
4
class Base {
  public:
     virtual double F( double ) = 0; // Pure virtual, unless you want to provide a default implementation
};


Topic archived. No new replies allowed.