From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,b09c5ba52b0f85c8 X-Google-Attributes: gid109fba,public X-Google-Thread: fee84,b09c5ba52b0f85c8 X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-05-26 12:05:06 PST Path: bga.com!news.sprintlink.net!demon!uknet!lyra.csx.cam.ac.uk!pipex!swrinde!gatech!newsxfer.itd.umich.edu!gumby!wupost!spool.mu.edu!cass.ma02.bull.com!bullnews.bull.fr!clbull.frcl.bull.fr!mip3035!freja From: E.Frejaville@frcl.bull.fr (Etienne Frejaville) Newsgroups: comp.unix.osf.osf1,comp.lang.c++ Subject: Re: DEC C++ template problem Message-ID: <1431@clbull.frcl.bull.fr> Date: 26 May 94 12:34:16 GMT References: <2r8g7q$gsq@fermat.mayo.edu> Sender: news@clbull.frcl.bull.fr Reply-To: E.Frejaville@frcl.bull.fr (Etienne Frejaville) Followup-To: comp.unix.osf.osf1 Organization: Bull S.A - France Xref: bga.com comp.unix.osf.osf1:1716 comp.lang.c++:16752 In article <2r8g7q$gsq@fermat.mayo.edu>, stan@chirpa.mayo.edu (Andrew Staniszewski) writes: |> |> |> I need to write some code taking advantage of the flexability of templates. |> But the DEC C++ compiler is being rather noisome. My specific problem |> lies in passing a member function from a paramatized type, specificly |> |> ----------------------------------------------------------------------------- |> include |> class foo |> { |> public: |> int barr() { return 0;} |> }; |> |> template int func(type data,int (type::*memberFunc)()) |> { |> return data.memberFunc(); |> } |> |> |> void main() |> { |> foo data; |> |> cout << func(data,&foo::barr) << endl; |> } |> -------------------------------------------------------------------------------- |> |> |> generates the message from the compiler |> |> chirpa> cxx -c test.cxx |> test.cxx:8: error: In the declaration of "memberFunc", type is not a class, |> struct, or union type. |> Compilation terminated with errors. |> The only way I can get this to compile is to declare memberFunc to belong |> explicily to foo. I THINK this is a compiler bug, but can anyone tell me for sure? Your problem is that you try to invoke memberFunc as if it was a member function. But you have declared it as a pointer to member function. Use the right operator : the pointer to member operator '.*'. replace : return data.memberFunc(); by : return (data.*memberFunc)(); and it will work fine. I don't have interests in the products of DEC, but read CAREFULLY the ARM or any recent ANSI C++ draft before thinking of a compiler bug. --------Etienne FREJAVILLE---Bull S.A --------------------------------- OSS/HEU/ACS/LPS/TOPAS e-mail: E.Frejaville@frcl.bull.fr Rue Jean-Jaures, F6/1D/17, BP 53 tel: (33-1) 30806548 78340 Les Clayes-sous-Bois, France Fax: (33-1) 30807950