From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4495 invoked by alias); 22 Sep 2006 23:47:36 -0000 Received: (qmail 4485 invoked by uid 22791); 22 Sep 2006 23:47:35 -0000 X-Spam-Check-By: sourceware.org Received: from nf-out-0910.google.com (HELO nf-out-0910.google.com) (64.233.182.184) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 22 Sep 2006 23:47:33 +0000 Received: by nf-out-0910.google.com with SMTP id l24so1187473nfc for ; Fri, 22 Sep 2006 16:47:31 -0700 (PDT) Received: by 10.48.14.4 with SMTP id 4mr2705796nfn; Fri, 22 Sep 2006 16:47:31 -0700 (PDT) Received: by 10.49.61.8 with HTTP; Fri, 22 Sep 2006 16:47:30 -0700 (PDT) Message-ID: <366c6f340609221647o49613c18o86bb2b84986f7890@mail.gmail.com> Date: Fri, 22 Sep 2006 23:47:00 -0000 From: "Peng Yu" To: gcc-help@gcc.gnu.org Subject: Re: Problem when using template as the base class? In-Reply-To: <366c6f340609221250p6d328af1l96866662e05c63b7@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <366c6f340609221250p6d328af1l96866662e05c63b7@mail.gmail.com> 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 X-SW-Source: 2006-09/txt/msg00242.txt.bz2 > I have the following program. It also includes the non-template > equivalent class, which works fine. If you uncomment the comments, you > will see the compiler errors. The errors are also shown below. Do you > know what is wrong? Is it a bug of the compiler? > > BTW, I use g++-3.4. I corrected the error by adding template keyword. But I don't understand why "template" keyword is need. Would you please help me? #include #include class base_arguments { public: base_arguments() {} protected: boost::program_options::variables_map _vm; }; template class plot_arguments : public T { public: plot_arguments() {} int boundary_pad() const { return T::_vm["boundary_pad"].template as(); } }; class plot_arguments1 : public base_arguments { public: plot_arguments1(){} int boundary_pad() const { return base_arguments::_vm["boundary_pad"].as(); } }; int main(int argc, char *argv[]) { plot_arguments arg(); plot_arguments1 arg1(); }