🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #9

BUG?

#9
From: Tracey Beauchat
Date: Wed, 28 Oct 1992 08:15
76 lines
2323 bytes
It appears that templates are implemented in the latest g++, right?  Well
when I try to compile the following simple test program I get the following
compiler errors:

tracey@md> g++ -c temp.c 
temp.c:16: parse error before `>'
temp.c:35: warning: return type for `main' changed to integer type
temp.c:10: parse error before `>'
temp.c: In function `int  main (...)':
temp.c:13: template for method `junk' doesn't match any in class `junk<junk2>'

It appears that g++ can't handle passing template classes into methods.
Is this true?

-Tracey

------------ THE PROGRAM --------------

#include <iostream.h>

template <class T>
class junk {
  T *data;
  int size;

public:
  junk(int n) { data = new T[n]; size = n; }
  junk(junk<T> &);
  void Put(int i, T d) { data[i] = d; }
  T& Get(int i);
};

template <class T>
junk<T>::junk(junk<T> &j)
{
   data = new T[j.size];
   size = j.size;
}

template <class T> 
T& junk<T>::Get(int i)
{
  return(data[i]);
}

struct junk2 {
  int d;
};


void
main(void)
{
   junk <junk2> test(2);
   junk2 a;

   a.d = 2;

   test.Put(0, a);
   a = test.Get(0);
}

-------------- END --------------

-------------------------------------------------------------------
                        Tracey A. Beauchat
-------------------------------------------------------------------
*********   *********   ********
*********   ***   ***   ***   ***    The College of William & Mary
   ***      *********   ********     Department of Computer Science
   ***      ***   ***   ***   ***    Williamsburg, VA  23185
   ***      ***   ***   ********
-------------------------------------------------------------------
       EMAIL: tracey@cs.wm.edu         PHONE: (804)221-3468
-------------------------------------------------------------------
         <-[ " The truth is a virus! " - Harry Hardon ]->
Technical Details
Message-ID: <9210281815.AA15353@md.cs.wm.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!uwm.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cs.wm.edu!tracey

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!uwm.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cs.wm.edu!tracey
From: tracey@cs.wm.edu (Tracey Beauchat)
Newsgroups: gnu.gcc.bug
Subject: BUG?
Message-ID: <9210281815.AA15353@md.cs.wm.edu>
Date: 28 Oct 92 08:15:54 GMT
Article-I.D.: md.9210281815.AA15353
Sender: gnulists@ai.mit.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 76
Approved: bug-gcc@prep.ai.mit.edu