From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11768 invoked by alias); 27 Aug 2004 12:27:00 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 11751 invoked from network); 27 Aug 2004 12:26:59 -0000 Received: from unknown (HELO psmtp.com) (12.158.35.214) by sourceware.org with SMTP; 27 Aug 2004 12:26:59 -0000 Received: from source ([192.150.22.7]) by exprod6ob4.obsmtp.com ([12.158.35.250]) with SMTP; Fri, 27 Aug 2004 05:26:55 PDT Received: from inner-relay-1.corp.adobe.com (inner-relay-1 [153.32.1.51]) by smtp-relay-7.sea.adobe.com (8.12.10/8.12.10) with ESMTP id i7RCQsPB027917; Fri, 27 Aug 2004 05:26:55 -0700 (PDT) Received: from iplan-mn (iplan-mn.corp.adobe.com [130.248.25.5]) by inner-relay-1.corp.adobe.com (8.12.9/8.12.9) with ESMTP id i7RCQsTk001120; Fri, 27 Aug 2004 05:26:54 -0700 (PDT) Received: from mn-eljay-a51m.adobe.com ([130.248.178.89]) by iplan-mn.corp.adobe.com (iPlanet Messaging Server 5.2 HotFix 1.21 (built Sep 8 2003)) with ESMTP id <0I3300IMCUKTQ6@iplan-mn.corp.adobe.com>; Fri, 27 Aug 2004 07:26:54 -0500 (CDT) Date: Fri, 27 Aug 2004 15:04:00 -0000 From: Eljay Love-Jensen Subject: Re: template-id does not match any template declaration In-reply-to: X-Sender: eljay@iplan-mn.corp.adobe.com To: learning c++ , gcc-help@gcc.gnu.org Message-id: <6.1.2.0.2.20040827072207.01e4ae88@iplan-mn.corp.adobe.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT References: X-SW-Source: 2004-08/txt/msg00256.txt.bz2 Hi, You were almost there! Just a little syntax tweak for your separate definition of your member function of your explicit template specialization for pair::module. (See below.) Also, I changed the return statement on your general pair template pair::module to something more suitable. Caution, there is a std::pair. Your ::pair is okay, but could be a little better protected by putting your pair class in your own namespace. Or, make sure you never do a "using namespace std" anywhere (I disparage "pulling in the std uberverse namespace" on general principle). HTH, --Eljay ------------------------------- #include using std::cout; template class pair { T value1; T value2; public: pair(T first, T second) { value1 = first; value2 = second; } T module() { return T(); } }; template <> class pair { int value1; int value2; public: pair(int first, int second) { value1 = first; value2 = second; } int module(); }; int pair::module() { return value1 % value2; } int main() { pair myints(100, 75); pair myfloats(100.0, 75.0); cout << myints.module() << '\n'; cout << myfloats.module() << '\n'; }