473,761 Members | 5,163 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compilation error of method of base template class - XCode 2.4.1

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(cons t RectGP &rectGP)
{
SetCoordinates( rectGP);
}
RectDouble(cons t fixedrect& fixedRect)
{
SetCoordinates( fixedRect);
}
void SetCoordinates( const fixedrect& fixedRect)
{
SetLeft(Fix2Dou ble(fixedRect.l eft)); // Makro Fix2Double zwraca double
SetTop(Fix2Doub le(fixedRect.to p));
SetRight(Fix2Do uble(fixedRect. right));
SetBottom(Fix2D ouble(fixedRect .bottom));
}
void SetCoordinates( const RectGP &rectGP)
{
SetLeft(rectGP. m_fLeft);
SetTop(rectGP.m _fTop);
SetRight(rectGP .m_fRight);
SetBottom(rectG P.m_fBottom);
}
};
--
Regards
Aleksander W
Nov 21 '06 #1
2 2079
Write this->SetLeft(
or RectBase<T>::Se tLeft(

Nov 21 '06 #2

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(cons t RectGP &rectGP)
{
SetCoordinates( rectGP);
}
RectDouble(cons t fixedrect& fixedRect)
{
SetCoordinates( fixedRect);
}
void SetCoordinates( const fixedrect& fixedRect)
{
SetLeft(Fix2Dou ble(fixedRect.l eft)); // Makro Fix2Double zwraca double
Fix2Double is of type double which is not
necessarily T

Nov 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
3623
by: Dave Rahardja | last post by:
OK, so I've gotten into a philosophical disagreement with my colleague at work. He is a proponent of the Template Method pattern, i.e.: class foo { public: void bar() { do_bar(); } protected: virtual void do_bar() {} };
0
1664
by: Zach | last post by:
Using Dev-C++ 4.9.8.5 I get error: Compiler: Default compiler Executing g++.exe... g++.exe "C:\winroot\src\c++\stupid_tricks\functor_trick.cpp" -o "C:\winroot\src\c++\stupid_tricks\functor_trick.exe" -I"C:\DEV-CPP\include\c++" -I"C:\DEV-CPP\include\c++\mingw32" -I"C:\DEV-CPP\include\c++\backward" -I"C:\DEV-CPP\include" -L"C:\DEV-CPP\lib" C:/winroot/src/c++/stupid_tricks/functor_trick.cpp: In member function
4
2904
by: daniel.w.gelder | last post by:
I wrote a template class that takes a function prototype and lets you store and call a C-level function, like this: inline string SampleFunction(int, bool) {..} functor<string (int, bool)> myFunctor = SampleFunction; string result = myFunctor(7, true); Works great thanks to the help from this group. Here's the guts so far for two-arity:
9
3675
by: Daniel Kay | last post by:
Hello! I have written two template classes which implement the observerpattern in C++. I hope I manage to desribe the problem I have. template<class T> class Observer { /* ... */ }; template<class T> classSubject {
11
3097
by: Niels Dekker - no reply address | last post by:
The following attempt to pass my template "Base" as a template template argument was rejected by Microsoft VC++ 8.0 (2005), while it still works on VC++ 7.1 (2003). Is it correct C++? And is there a workaround? template <typename T> class Base { }; template <typename U, template <typename> class TempTemp> class Derived;
9
2664
by: Jerome Durand | last post by:
Hello, I'm trying to write something along the following lines but I cannot get this to compile. template <typename derivedstruct Base { typedef typename derived::valueType valueType; virtual valueType Value() = 0; };
4
1958
by: subramanian100in | last post by:
Suppose the following program is named x.cpp #include <iostream> #include <vector> using namespace std; template <class T> class Vec : public vector<T> {
2
1857
by: subramanian100in | last post by:
consider the following program #include <iostream> using namespace std; class Rec { public: Rec(int arg = 10) : val(arg) { }
1
2812
by: BSand0764 | last post by:
I'm getting an error that I can't seem to resolve. When I compile the Functor related logic in a test program, the files compile and execute properly (see Listing #1). However, when I incorporate the same logic within my simulation, the class that implements the functor logic has problems compiling. I get the following errors: -- Building myTest.cpp --
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9948
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6603
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.