Q:

Error in main() for function call from a derived class C++

//Newton-Raphson Method:

#include <iostream>
#include <cmath>

using namespace std;

class ClassNewton {
    public: 
    double NewtonRaphson(double x0, double epsilon, double f(double), double df(double));
    virtual double f(double) = 0; 
    virtual double df(double) = 0;  
};

double ClassNewton::NewtonRaphson(double x0, double epsilon, double f(double), double df(double)){
        double xold = x0;
        double diff;
        double xnew;
    do {
        xnew = xold - (f(xold)/df(xold));
        xold = xnew;
        } while (abs(diff) > epsilon); 
        return xnew;
}               

class derivedClass:public ClassNewton{
    public:
    double f(double x){ 
    double function = (x * x) + (2 * x) + 2;
    return function;
    }

    double df(double x){
    double derivative = (2 * x) + 2;
    return derivative;
    }
};

int main() {
    derivedClass n;
    double root;
    double x0 = 1.0;
    double epsilon = 0.00001;
    root = n.NewtonRaphson(x0, epsilon, f(root), df(root));
    cout << "The root of the function is  " << root << endl;
    return 0;
}

I checked the code up to the main function using an empty main and it could get compiled with no errors. However, when I integrate the main, I get the following error:
NewtonRaphson.cc: In function ‘int main()’:
NewtonRaphson.cc:52:44: error: ‘f’ was not declared in this scope
NewtonRaphson.cc:52:54: error: ‘df’ was not declared in this scope
NewtonRaphson.cc:53:47: error: expected ‘;’ before ‘)’ token

I would appreciate some explanations, I suspect I am using the virtual functions in a wrong way.

A:

First of all in this statement
cout << "The root of the function is  ", root);
                                       ^^^^ ^^^

there is invalid expression.
As for other errors then you have to use an object name that to call non-static member functions of a class.
For example
n.f(root)

or
n.df(root)

Take into account that this declaration
double NewtonRaphson(double x0, double epsilon, double f(double), double df(double));

is invalid because you are going to use as arguments non-static member functions f and df while the corresponding parameters are declared as non-member functions.
There is no need to define these two parameters of the function because you could simply call these member functions within the body of NewtonRaphson.

