Compilation error of method of base template class - XCode 2.4.1

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);
}
};
 
D

dasjotre

AlexW said:
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

Fix2Double is of type double which is not
necessarily T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top