home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!noc.near.net!news.cs.brandeis.edu!binah.cc.brandeis.edu!DERNIS
- From: dernis@binah.cc.brandeis.edu
- Subject: Templates
- Message-ID: <1992Dec13.231649.4904@news.cs.brandeis.edu>
- Sender: news@news.cs.brandeis.edu (USENET News System)
- Reply-To: dernis@binah.cc.brandeis.edu
- Organization: Brandeis University
- Date: Sun, 13 Dec 1992 23:16:49 GMT
- Lines: 33
-
- Hi,
- This is a fairly simple template question, I hope.
- I have written a template class, which has been tested and
- appears to work (mostly at least). Now I tried to use and I
- have found a problem.
-
- The class is a matrix class, and works with all numerical types
- (I have only tested the two that I need - but presumably).
-
- Now I want to declare a function which returns a complex Matrix.
-
- So I wrote,
-
- Matrix<complex> function();
-
- But I discovered a problem immediately, that this interprets this
- as instance of Matrix<complex>, not a function declaration. It now
- occurs to me that indeed that is exactly what I have written, and
- it rightfully complains that I left out the arguments.
-
- Does this mean at that I have to template this function too, and do
- something like:
-
- template <class T>
- void function(Matrix<T>& ref_to_value);
-
- Is there a way I can write a function that will return a complex
- instance of my matrix class without writing the function as a template.
- The above my be acceptable, even better as it does not generate a
- temporary, but still. . .
-
- Thanks,
- Mitch Dernis
-