Listing 4: Exponential regression calculation class derived from the LinearRegression class

/*  expreg.h */
#ifndef _EXPREG_H_
#define _EXPREG_H_

#include <math.h>
#include "linreg.h"

class ExponentialRegression : public LinearRegression
{
    friend ostream& operator<<(ostream& out, 
                               ExponentialRegression& er);

    public:
        ExponentialRegression(Point2D *p = 0, long size = 0);
        ExponentialRegression(double *x, double *y, 
                              long size = 0);

virtual void addXY(const double& x, const double& y)
        {
            LinearRegression::addXY(x, log(y));
        }

virtual double getA() const { return exp(a); }

virtual double estimateY(double x) const
        {
            return (exp(a) * exp(b * x));
        }
};

#endif                      // end of expreg.h