public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* template problem
@ 2002-10-09  9:33 andy
  2002-10-09 10:18 ` Eljay Love-Jensen
  0 siblings, 1 reply; 9+ messages in thread
From: andy @ 2002-10-09  9:33 UTC (permalink / raw)
  To: gcc-help

I'm having trouble compiling the following in gcc3.2:

template <class FilterClass, class DataClass = CDataCOLORREF>

class C2PassScale 
{
public:
    typedef DataClass::_DataType _DataType; //ERROR -see below
    typedef DataClass::_RowType _RowType;
    ....


//class CDataCOLORREF is declared below in the same file
class CDataCOLORREF {
public:
  typedef unsigned long_DataType;
....

ERROR above reads:
"ISO C++ forbids declaration of _DataType with no type"

Now,  if I understand the code correctly, the _DataType variable of the
C2PassScale class is typedef'ed to be the same as _DataType variable of the
the CDataCOLORREF class, i.e, long.
It looks like gcc cannot figure out what type the _DataType variable of
C2PassScale class needs to be.
I wonder if anyone can help finding a workaround or maybe a compile option I
need to turn on

Thanks in advance
Andy


^ permalink raw reply	[flat|nested] 9+ messages in thread
[parent not found: <2F05A390F72A0A409390E016D23E45E8042DBE10@ns-bco-mse4.im.battelle.org>]
* Template problem
@ 2001-04-02  7:20 jpyubero
  2001-04-02 21:00 ` Alexandre Oliva
  0 siblings, 1 reply; 9+ messages in thread
From: jpyubero @ 2001-04-02  7:20 UTC (permalink / raw)
  To: gcc-help

Hi,

        I compiled the program Xvision perfetly under RedHat, but now I`ve
install Mandrake and It's no possible.
When I typing make the exit is:

 make

g++  -g -I- -I. -I~/xvision/include -I~/xvision -w -c prueba.cxx -o prueba.o
In file included from Video.hh:41,
                 from CWindow.hh:34,
                 from BasicFeature.hh:37,
                 from FTypes.hh:32,
                 from Line.hh:33,
                 from prueba.cxx:5:
Image.hh:31: return type specified for `operator XVImage<float>'
make: *** [prueba.o] Error 1


The file Image.hh is:

    #ifndef Image_hh
#define Image_hh

#include "Tracker.hh"
#include "XVImage.hh"

class Image : public XVImage<int>
{
  public:

  Image (int ncols_in = 0, int nrows_in = 0)
    : XVImage<int>(nrows_in, ncols_in)
  {}

  Image (XVImage<int>& im)
    : XVImage<int>(im)
  {}


#if (XV_OS == XV_IRIX)
  operator XVImage<float>() {
    float* floatData = new float[storesize];

    for (int i = 0; i < storesize; i++)
      floatData[i] = (float)image[i];
    XVImage<float> newImage(nrows, ncols, floatData
    delete floatData;
    return newImage;
  }
#else
  XVImage<float> operator XVImage<float>()
{                                                          //Number of line 31
    float* floatData = new float[storesize];

    for (int i = 0; i < storesize; i++)
      floatData[i] = (float)image[i];
    XVImage<float> newImage(nrows, ncols, floatData
    delete floatData;
    return newImage;
  }
#endif

};

#endif Image_hh




And the lines where is implemented in another file is:

template <class T> XVImage<T> &operator >>(const ColVector &x,XVImage<T> &y);
template <class T> XVImage<T> &operator >>(const RowVector &x,XVImage<T> &y);

Can anyboby help me?


Sorry for my english

Thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Template problem
@ 1999-12-28 13:11 Michael Ben-Gershon
  1999-12-31 22:24 ` Michael Ben-Gershon
  2000-01-02  4:22 ` Alex Vinokur
  0 siblings, 2 replies; 9+ messages in thread
From: Michael Ben-Gershon @ 1999-12-28 13:11 UTC (permalink / raw)
  To: help-gcc

I am having problems with templates on gcc-2.95.2. I am sure
that the code worked on some earlier version of gcc, but I
don't recall exactly which version it was.

I have a Range class defined as:

template <class T, T lower, T upper>
class Range
{
...
};

It has a number of non-member functions defined for the various
operators. In particular, it has the following defined:

template<class T, T lower, T upper>
ostream&
operator<< (ostream& out_stream, const Range<T, lower, upper>& the_value);

In the main program, I have

int main()
{
  Range<int, -5, 5> f = -5;

  cout << endl;
  
  cout << "Number is: " << f << endl;
...

When compiling (all the code, including the implementation of the 
function above, is in one file) I get the following error:

test_range.cc: In function `int main()':
test_range.cc:18: no match for `ostream & << Range<int,-5,5> &'
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../include/g++-3/iostream.h:77:
candidates are: class ostream & ostream::operator <<(char)
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../include/g++-3/iostream.h:78:                
class ostream & ostream::operator <<(unsigned char)
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../include/g++-3/iostream.h:79:                
class ostream & ostream::operator 

etc, etc, etc ...

The strange thing is that I have a derived class, which behaves fine!
It is defined as:

template<int lowest, int highest>
class Floor_Number : public Range<int, lowest, highest>
{
...
};

With the ostream stuff defined as:

template<int lowest, int highest>
ostream&
operator<< (ostream& out_stream, const Floor_Number<lowest, highest>&
the_value);

and is used in the test program as:

Floor_Number<-3, 10> Ff = -5;

cout << "The floor is: " << Ff << endl;

What is wrong with the Range stuff? If it is wrong, how is it that the derived
class Floor_Number is OK?

Thanks,

Michael Ben-Gershon
mybg@netvision.net.il

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2002-10-09 18:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-09  9:33 template problem andy
2002-10-09 10:18 ` Eljay Love-Jensen
     [not found] <2F05A390F72A0A409390E016D23E45E8042DBE10@ns-bco-mse4.im.battelle.org>
2002-10-09 11:46 ` andy
  -- strict thread matches above, loose matches on Subject: below --
2001-04-02  7:20 Template problem jpyubero
2001-04-02 21:00 ` Alexandre Oliva
1999-12-28 13:11 Michael Ben-Gershon
1999-12-31 22:24 ` Michael Ben-Gershon
2000-01-02  4:22 ` Alex Vinokur
2000-04-01  0:00   ` Alex Vinokur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).