Dave
2010-02-14 07:26:32 UTC
Hi folks,
Got the following class hierarchy, and am getting a strange compile
error from it:
class RootFinder
{
public:
virtual ~RootFinder(){}
double findRoot( const Function1D& func, double guess ) const;
virtual double findRoot( const Function1D& func, double min, double
max ) const = 0;
private:
bool findGoodInterval( const Function1D& func, double guess, double&
min, double& max ) const;
};
class BisectionRootFinder : public RootFinder
{
public:
BisectionRootFinder(){}
virtual double findRoot( const Function1D& func, double min, double
max ) const;
};
If I then try to use the second class like so:
BisectionRootFinder rootFinder;
const double root = rootFinder.findRoot( func, guess );
I get the following compile error on that second line :
error C2660: 'BisectionRootFinder::findRoot' : function does not
take 2 arguments
I'm not sure why this is happening, as it should be able to find the
non-virtual version of findRoot(...) that is in the base class. I can
coax it to find it by doing the following:
BisectionRootFinder bisectRootFinder;
RootFinder& rootFinder = bisectRootFinder;
const double root = rootFinder.findRoot( func, guess );
and all works fine. But, why do I need to go through that extra step?
Am I declaring something wrong, or is VC just misbehaving? If it
matters, I am using Visual Studio 2008 Express (version 9.0.30729.1
SP)
Thanks.
Got the following class hierarchy, and am getting a strange compile
error from it:
class RootFinder
{
public:
virtual ~RootFinder(){}
double findRoot( const Function1D& func, double guess ) const;
virtual double findRoot( const Function1D& func, double min, double
max ) const = 0;
private:
bool findGoodInterval( const Function1D& func, double guess, double&
min, double& max ) const;
};
class BisectionRootFinder : public RootFinder
{
public:
BisectionRootFinder(){}
virtual double findRoot( const Function1D& func, double min, double
max ) const;
};
If I then try to use the second class like so:
BisectionRootFinder rootFinder;
const double root = rootFinder.findRoot( func, guess );
I get the following compile error on that second line :
error C2660: 'BisectionRootFinder::findRoot' : function does not
take 2 arguments
I'm not sure why this is happening, as it should be able to find the
non-virtual version of findRoot(...) that is in the base class. I can
coax it to find it by doing the following:
BisectionRootFinder bisectRootFinder;
RootFinder& rootFinder = bisectRootFinder;
const double root = rootFinder.findRoot( func, guess );
and all works fine. But, why do I need to go through that extra step?
Am I declaring something wrong, or is VC just misbehaving? If it
matters, I am using Visual Studio 2008 Express (version 9.0.30729.1
SP)
Thanks.