Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Problem in c++ (http://www.go4expert.com/forums/problem-in-cpp-t18630/)

sdmahapatra 20Jul2009 15:16

Problem 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
Code:

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 :

Code:

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

and the main function :
Code:

int main()
  {
  //Base obj;
  Derived obj;
  obj.F(1.0);
  return 0;
  }

I'm getting an error :
Quote:

error C3861: 'F': identifier not found
I know this is a correct error but I need to call a derived class function into the base class function.Is it possible any how?? or I have to go different way like template etc
So how to solve this problem.
With Warm Regards
sdmahapatra


All times are GMT +5.5. The time now is 15:36.