J
James Aguilar
I am having a problem with a derived class not seeing an operator in a base
class.
Suppose I have a base class:
template <typename T>
class Array
{
protected:
T *m_array;
public:
//...
Array<T> &operator =(const Array<T> &other);
Array<T> &operator =(const T &other);
//...
};
Then I have this derived class:
class Vector : public Array<double>
{
//...
};
When I try to say
Vector v(20);
v = 3.14;
I receive this error:
lab3-vector.cpp:22: error: no match for 'operator=' in 'vector2 =
3.14000000000000012434497875801753252744674682617e+0'
vector.hpp:11: error: candidates are: Vector& Vector:perator=(const Vector&)
But it should call Array<double> &operator =(const double &d). Can anyone say
why it doesn't?
- JFA1
class.
Suppose I have a base class:
template <typename T>
class Array
{
protected:
T *m_array;
public:
//...
Array<T> &operator =(const Array<T> &other);
Array<T> &operator =(const T &other);
//...
};
Then I have this derived class:
class Vector : public Array<double>
{
//...
};
When I try to say
Vector v(20);
v = 3.14;
I receive this error:
lab3-vector.cpp:22: error: no match for 'operator=' in 'vector2 =
3.14000000000000012434497875801753252744674682617e+0'
vector.hpp:11: error: candidates are: Vector& Vector:perator=(const Vector&)
But it should call Array<double> &operator =(const double &d). Can anyone say
why it doesn't?
- JFA1