From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10ba33,f7119c816cf89e17 X-Google-Attributes: gid10ba33,public X-Google-Thread: fee84,f7119c816cf89e17 X-Google-Attributes: gidfee84,public X-Google-Thread: fc89c,f7119c816cf89e17 X-Google-Attributes: gidfc89c,public From: mgjones@vegauk.co.uk (Martin G. Jones) Subject: Re: Help w/ templated sub-classes Date: 1997/08/14 Message-ID: <33f34ce4.35755749@news.demon.co.uk>#1/1 X-Deja-AN: 264220762 X-NNTP-Posting-Host: mjones.vegauk.co.uk [194.217.20.88] References: <33E69610.1B1F@texas.net> Newsgroups: gnu.g++.help,comp.unix.programmer,comp.unix.osf.osf1 On Mon, 04 Aug 1997 21:55:12 -0500, magrasjc@texas.net wrote: >Greetings everyone, > >I am trying to get the following code to compile on a g++ 2.7.2.2 >and libg++ 2.7.2 on DEC UNIX 3.2... but I cant discern what the >external function defintion's header should look like... > >Thanks in advance for your help, > >J.C. Magras > >#include // yields unary_function template > >***** given this generic template >template >class jack:pubic unary_function >{ >public: >Result& jack::operator(Protocol&){}; >}; > >***** given this template specialization >template >class jack:public unary_function >{ >friend class pTCPIP; >public: > Result& jack::operator()( Protocol &) ; >}; >************ >what is the function signature/header for: >pTCPIP& jack :: operator() (pTCPIP & e) { } ? I haven't got a copy of g++ to try this on but it compiles with the DEC CXX compiler. Your main problem is that the syntax of your specialised class is incorrect. I have highlighted the differences with comments. // functional required on dec compiler. #include // yields unary_function template // I presume you meant public and not pubic :-) template class jack : public unary_function { public: // presumably operator() - a set of parentheses were missing // in the original code Result& jack::operator()(Protocol&) {}; }; class pTCPIP; // note syntax for specialising template class // i.e. no template<...> construct class jack { friend class pTCPIP; public: // no need to explicitly scope the operator. If you did, use: // jack:: ... not jack:: // specify the concrete type, not Result for ret val. pTCPIP& operator()(pTCPIP&); }; // Define the function out of line: pTCPIP& jack::operator()(pTCPIP& p) { return p; // do whatever } Martin. ************ Martin G. Jones, Software Engineer mgjones@vegauk.co.uk