home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!munnari.oz.au!titan!cetra!lightw
- From: lightw@cetra.trl.OZ.AU (Liron Lightwood)
- Subject: Help. Is this a templates bug?
- Message-ID: <1993Jan8.003633.17575@trl.oz.au>
- Sender: root@trl.oz.au (System PRIVILEGED Account)
- Organization: Telecom Research Labs, Melbourne, Australia
- Date: Fri, 8 Jan 1993 00:36:33 GMT
- Lines: 52
-
- I was experimenting with templates for use in our project, when I managed to
- obtain a compiler error message which effectively said that there was an
- error with the argument given to the constructor, even though what it got
- was identical to what it expected.
-
- Is this a bug with templates, or the compiler I am using?
- How can I overcome it?
-
- I am using an AT&T C++ 3.01 compiler on a SUN SPARCstation running under
- SUNOS 4.1.1.
-
- Here is the code, followed by the error message.
-
- -------------------------------------------------------------------
- class x
- {
- public:
- int x_int() { return 21; }
- // x_int is a member function of class x which returns an
- // integer
- };
-
- template <class A,class B> class GetFunc {
- public:
- B (A::*a_b_func)();
- // func contains address of a member function of class A
- // (e.g. class x) which returns an B (e.g. an int)
-
- GetFunc(B (A::*f)()) : a_b_func(f) {} // constructor
- };
-
- main()
- {
- GetFunc<x,int> getfunc_x_int ( &(x::x_int) );
- }
-
-
- --------------------------------------------------------------------
-
- Here is the compiler error message:
-
- /usr/local/bin/CC a.c
- CC a.c:
- "a.c", line 20: error: bad argument 1 type for GetFunc <x, int >::GetFunc__pt__4_1xi(): int (x::*)() ( int (x::*)() expected)
-
- ------------------------------------------------------------------------
-
-
- Liron Lightwood Internet : r.lightwood@trl.oz.au
- Telecom Research Laboratories Phone : +61 3 253 6535
- 770 Blackburn Road Snail : P.O. Box 249 Clayton 3168 Australia
- Clayton Vic. 3168 Australia Disclaimer : My views are not my company's
-