A
AlexW
Hi,
I have error of compilation when I compile below template classes in xcode 2.4.1 on MacOSX10.4.8. This xcode uses GCC 4.0.1
error: there are no arguments to 'SetLeft' that depend on a template parameter, so a declaration of 'SetLeft' must be available
error: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
The same code compiles successfuly on VisualC++2005 Express (WinXP) and CodeWarrior10.0 (MacOsX).
Thanks for any suggestions.
template<class T>
class RectBase
{
public:
RectBase()
{
m_Left = static_cast<T>(0);
m_Top = static_cast<T>(0);
m_Right = static_cast<T>(0);
m_Bottom = static_cast<T>(0);
}
T GetLeft() { return m_Left; }
T GetTop() { return m_Top; }
T GetRight() { return m_Right; }
T GetBottom() { return m_Bottom; }
T GetHeight()
{
return (m_Bottom - m_Top);
}
T GetWidth()
{
return (m_Right - m_Left);
}
void SetLeft(const T &left)
{
m_Left = left;
}
void SetTop(const T &top)
{
m_Top = top;
}
void SetRight(const T &right)
{
m_Right = right;
}
void SetBottom(const T &bottom)
{
m_Bottom = bottom;
}
void SetCoordinates(T m_Left, T m_Top, T m_Right, T m_Bottom)
{
this->m_Left = m_Left;
this->m_Top = m_Top;
this->m_Right = m_Right;
this->m_Bottom = m_Bottom;
}
private:
T m_Left;
T m_Top;
T m_Right;
T m_Bottom;
};
template<class T>
class RectDouble : public RectBase<T>
{
public:
RectDouble(const RectGP &rectGP)
{
SetCoordinates(rectGP);
}
RectDouble(const fixedrect& fixedRect)
{
SetCoordinates(fixedRect);
}
void SetCoordinates(const fixedrect& fixedRect)
{
SetLeft(Fix2Double(fixedRect.left)); // Makro Fix2Double zwraca double
SetTop(Fix2Double(fixedRect.top));
SetRight(Fix2Double(fixedRect.right));
SetBottom(Fix2Double(fixedRect.bottom));
}
void SetCoordinates(const RectGP &rectGP)
{
SetLeft(rectGP.m_fLeft);
SetTop(rectGP.m_fTop);
SetRight(rectGP.m_fRight);
SetBottom(rectGP.m_fBottom);
}
};
I have error of compilation when I compile below template classes in xcode 2.4.1 on MacOSX10.4.8. This xcode uses GCC 4.0.1
error: there are no arguments to 'SetLeft' that depend on a template parameter, so a declaration of 'SetLeft' must be available
error: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
The same code compiles successfuly on VisualC++2005 Express (WinXP) and CodeWarrior10.0 (MacOsX).
Thanks for any suggestions.
template<class T>
class RectBase
{
public:
RectBase()
{
m_Left = static_cast<T>(0);
m_Top = static_cast<T>(0);
m_Right = static_cast<T>(0);
m_Bottom = static_cast<T>(0);
}
T GetLeft() { return m_Left; }
T GetTop() { return m_Top; }
T GetRight() { return m_Right; }
T GetBottom() { return m_Bottom; }
T GetHeight()
{
return (m_Bottom - m_Top);
}
T GetWidth()
{
return (m_Right - m_Left);
}
void SetLeft(const T &left)
{
m_Left = left;
}
void SetTop(const T &top)
{
m_Top = top;
}
void SetRight(const T &right)
{
m_Right = right;
}
void SetBottom(const T &bottom)
{
m_Bottom = bottom;
}
void SetCoordinates(T m_Left, T m_Top, T m_Right, T m_Bottom)
{
this->m_Left = m_Left;
this->m_Top = m_Top;
this->m_Right = m_Right;
this->m_Bottom = m_Bottom;
}
private:
T m_Left;
T m_Top;
T m_Right;
T m_Bottom;
};
template<class T>
class RectDouble : public RectBase<T>
{
public:
RectDouble(const RectGP &rectGP)
{
SetCoordinates(rectGP);
}
RectDouble(const fixedrect& fixedRect)
{
SetCoordinates(fixedRect);
}
void SetCoordinates(const fixedrect& fixedRect)
{
SetLeft(Fix2Double(fixedRect.left)); // Makro Fix2Double zwraca double
SetTop(Fix2Double(fixedRect.top));
SetRight(Fix2Double(fixedRect.right));
SetBottom(Fix2Double(fixedRect.bottom));
}
void SetCoordinates(const RectGP &rectGP)
{
SetLeft(rectGP.m_fLeft);
SetTop(rectGP.m_fTop);
SetRight(rectGP.m_fRight);
SetBottom(rectGP.m_fBottom);
}
};