By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,710 Members | 1,613 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,710 IT Pros & Developers. It's quick & easy.

Compilation error of method of base template class - XCode 2.4.1

P: n/a
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);
}
};
--
Regards
Aleksander W
Nov 21 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Write this->SetLeft(
or RectBase<T>::SetLeft(

Nov 21 '06 #2

P: n/a

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

Nov 21 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.