home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19792 < prev    next >
Encoding:
Internet Message Format  |  1993-01-23  |  1.9 KB

  1. Xref: sparky comp.lang.c++:19792 comp.sys.sgi:19058
  2. Newsgroups: comp.lang.c++,comp.sys.sgi
  3. Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!yale!gumby!destroyer!fmsrl7!lynx.unm.edu!mimbres.cs.unm.edu!constellation!a.cs.okstate.edu!richarm
  4. From: richarm@a.cs.okstate.edu (MCINTYRE RICHARD D)
  5. Subject: Re: operator<<() with template arguments
  6. References: <larryj.727575410@westech>
  7. Message-ID: <1993Jan22.195345.25424@a.cs.okstate.edu>
  8. Organization: Oklahoma State University, Computer Science, Stillwater
  9. Date: Fri, 22 Jan 93 19:53:45 GMT
  10. Keywords: c++ templates
  11. Lines: 55
  12.  
  13. In article <larryj.727575410@westech> larryj@westech (Larry Jones) writes:
  14. >I have written a template class with multiple template arguments:
  15. >
  16. >template <class T, size_t dimensions>
  17. >class Foo {
  18. >public:
  19. >  // Stuff
  20. >
  21. >private:
  22. >
  23. >friend ostream& operator<< (ostream&, const Foo<T, dimensions>&);
  24. >};                // Foo
  25. >
  26. >However, when I try to define the operator<<() as defined below:
  27. >
  28. >ostream& operator<< (ostream& anOstream,
  29. >             template <class T, size_t dimensions>
  30. >             const Foo<T, dimensions>& aVector)
  31. >{
  32. >  return anOstream;
  33. >}
  34. >
  35. >my compiler (SGI CC v3.10), generates an error:
  36. >
  37. >"doit.C", line 36: error:  argument declaration syntax
  38.  
  39. Try something like ostream& operator<<( ostream& Ostream,
  40.                 const Foo<T, dimensions>& FooThing )
  41.             {
  42.             // do something.
  43.             return Ostream;
  44.             }
  45.  
  46. I'm not sure about your version of the compiler, but what I listed
  47. is pretty standard.  When your instantiating a tempate object, or
  48. listing parameters, I don't think you need the
  49.     "template <class T, size_t dimensions>" stuff.
  50. Consult your compiler documentation to be sure of the specific syntax
  51. on your version.
  52.  
  53. Be sure that you modify the declaration appropriately also.
  54.  
  55. >Thanks!
  56. >
  57. >Larry Jones
  58.  
  59. Hope that helps.
  60.  
  61.  
  62.  
  63. -- 
  64. Name :            Dallas McIntyre
  65. Occupation :        Student - Still looking for a "real" job.
  66. Favorite Far Side : Tarzan Introducing Himself to Jane.
  67. Email Address :        richarm@a.cs.okstate.edu
  68.