home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:19792 comp.sys.sgi:19058
- Newsgroups: comp.lang.c++,comp.sys.sgi
- 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
- From: richarm@a.cs.okstate.edu (MCINTYRE RICHARD D)
- Subject: Re: operator<<() with template arguments
- References: <larryj.727575410@westech>
- Message-ID: <1993Jan22.195345.25424@a.cs.okstate.edu>
- Organization: Oklahoma State University, Computer Science, Stillwater
- Date: Fri, 22 Jan 93 19:53:45 GMT
- Keywords: c++ templates
- Lines: 55
-
- In article <larryj.727575410@westech> larryj@westech (Larry Jones) writes:
- >I have written a template class with multiple template arguments:
- >
- >template <class T, size_t dimensions>
- >class Foo {
- >public:
- > // Stuff
- >
- >private:
- >
- >friend ostream& operator<< (ostream&, const Foo<T, dimensions>&);
- >}; // Foo
- >
- >However, when I try to define the operator<<() as defined below:
- >
- >ostream& operator<< (ostream& anOstream,
- > template <class T, size_t dimensions>
- > const Foo<T, dimensions>& aVector)
- >{
- > return anOstream;
- >}
- >
- >my compiler (SGI CC v3.10), generates an error:
- >
- >"doit.C", line 36: error: argument declaration syntax
-
- Try something like ostream& operator<<( ostream& Ostream,
- const Foo<T, dimensions>& FooThing )
- {
- // do something.
- return Ostream;
- }
-
- I'm not sure about your version of the compiler, but what I listed
- is pretty standard. When your instantiating a tempate object, or
- listing parameters, I don't think you need the
- "template <class T, size_t dimensions>" stuff.
- Consult your compiler documentation to be sure of the specific syntax
- on your version.
-
- Be sure that you modify the declaration appropriately also.
-
- >Thanks!
- >
- >Larry Jones
-
- Hope that helps.
-
-
-
- --
- Name : Dallas McIntyre
- Occupation : Student - Still looking for a "real" job.
- Favorite Far Side : Tarzan Introducing Himself to Jane.
- Email Address : richarm@a.cs.okstate.edu
-