home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:16438 gnu.g++.help:1447
- Newsgroups: comp.lang.c++,gnu.g++.help
- Path: sparky!uunet!ukma!wupost!sdd.hp.com!sgiblab!munnari.oz.au!cs.mu.OZ.AU!lenard
- From: lenard@mullian.ee.mu.OZ.AU (rohan james lenard)
- Subject: Template question with g++/gcc (again)
- Message-ID: <lenard.722028048@munagin>
- Summary: Need advise on a template question with g++/gcc
- Sender: news@cs.mu.OZ.AU
- Organization: Computer Science, University of Melbourne, Australia
- Date: Tue, 17 Nov 1992 19:20:48 GMT
- Lines: 55
-
- Whoops I made a mistake in my last post regarding templates under g++/gcc.
- Here is a repost with the correction made (and hightlighted) -
-
- I have a question regarding template and g++/gcc.
- According to the ARM something like this should be valid -
-
- > template<class T,char *V> class foo : public T
- ^^^^^^^^^^
- > {
- > foo(char *filename = V) {} ;
- > }
- ...
- > foo<int,"Hello"> a;
-
- However g++/gcc (2.2.2) complains pretty mightily about it.
- I have tried something like this -
-
- > class A
- > {
- > const char *str = "Hello";
- > operator char * () const { return str; }
- > }
- > template<class T,class V> class foo : public T
- ^^^^^^^^^^
- > {
- > foo(char *filename = (char *)V) {} ;
- > }
- >
- > foo<int,A> a;
-
- and it can be made to work, but it is not as elegant.
-
- Does anyone have a work around so that I can use something like the first
- example ? (NOTE: I may not have my code syntactically correct, as I am trying
- to remember it from a few days ago at a friends work, but I assume you get the
- idea)
-
- Any help would be appreciated.
-
- As an aside (sp?), the examples in the ARM for this sort of template class
- both work - did GNU only use these or what :-) ?
-
-
- Thanks in advance,
- Regards,
- Rohan
- --------------------------------------------------------------------------
- lenard@munagin.ee.mu.OZ.AU O O
- lenard@mundil.cs.mu.OZ.AU |
- lenard@ecr.mu.OZ.AU \_/
- --
- Rohan Lenard
- lenard@munagin.ee.mu.OZ.AU
- lenard@mundil.cs.mu.OZ.AU
- lenard@ecr.mu.OZ.AU
-