home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / cplus / 19034 < prev    next >
Encoding:
Text File  |  1993-01-12  |  1.5 KB  |  52 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!darwin.sura.net!uvaarpa!cv3.cv.nrao.edu!cv3!dschieb
  3. From: dschieb@muse.cv.nrao.edu (Darrell Schiebel)
  4. Subject: Template Quirk (Sun cfront/3.0 compiler)
  5. Message-ID: <DSCHIEB.93Jan12150130@muse.cv.nrao.edu>
  6. Sender: news@nrao.edu
  7. Organization: National Radio Astronomy Observatory
  8. Distribution: comp
  9. Date: Tue, 12 Jan 1993 20:01:30 GMT
  10. Lines: 40
  11.  
  12.  
  13.     I've run into a curious problem which must be a bug in the Sun
  14.     cfront 3.0.1 based compiler. Below I have a test program
  15.     which works as expected. However, if the inline function, "id",
  16.     is changed to define its body within the class, i.e. the commented
  17.     out line, it fails with the following errors:
  18.  
  19. "dum5.C", line 8: error:  qualified name A:: name not found in  fx
  20. "dum5.C", line 8:        error detected during the instantiation of fx <A>
  21.  "dum5.C", line 16:      is the site of the instantiation
  22.  
  23.     Anyone else ran into the "feature"?? Any ideas where the
  24.     compiler is going astray??
  25.  
  26.                         thanks,
  27.                         Darrell Schiebel
  28. -------------------X-----X-----X-----X-----X-----X---------------------
  29. #include <iostream.h>
  30. #include <string.h>
  31.  
  32. class FX {};
  33. template<class t> class fx : public FX{
  34. public:
  35.   fx *dup() {return(new fx());}
  36.   fx() {cout << "fx - " << t::name() << endl;}
  37. };
  38.  
  39. class A {
  40. public:
  41.   static const char *name() {return("A");}
  42. //const FX *id() {return(new fx<A>());}
  43.   inline const FX *id();
  44. };
  45. inline const FX *id() {return(new fx<A>());}
  46.  
  47. main() {
  48.  
  49.   fx<A> f;
  50.  
  51. }
  52.