public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Problem when using template as the base class?
@ 2006-09-22 19:50 Peng Yu
  2006-09-22 23:47 ` Peng Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Peng Yu @ 2006-09-22 19:50 UTC (permalink / raw)
  To: gcc-help

Hi,

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.

Thanks,
Peng


//////////////////////////////////////////////////
#include <iostream>
#include <boost/program_options.hpp>

class base_arguments {
  public:
    base_arguments() {}
  protected:
    boost::program_options::variables_map _vm;

};

/*template <typename T>
class plot_arguments : public T {
  public:
    plot_arguments() {}
    int boundary_pad() const {
      return T::_vm["boundary_pad"].as<int>();
    }

};*/

class plot_arguments1 : public base_arguments {
  public:
    plot_arguments1(){}
    int boundary_pad() const {
      return base_arguments::_vm["boundary_pad"].as<int>();
    }

};

int main(int argc, char *argv[])
{
  //plot_arguments<base_arguments> arg();
  plot_arguments1 arg1();
}

////////////////////////////////////////////////

The error that I get is:

main_1mod_bim_plot.cc: In member function `int
plot_arguments<T>::boundary_pad() const':
main_1mod_bim_plot.cc:16: error: expected primary-expression before
"int"
main_1mod_bim_plot.cc:16: error: expected `;' before "int"
main_1mod_bim_plot.cc:16: error: expected primary-expression before
"int"
main_1mod_bim_plot.cc:16: error: expected `;' before "int"
main_1mod_bim_plot.cc: At global scope:
main_1mod_bim_plot.cc:29: warning: unused parameter 'argc'
main_1mod_bim_plot.cc:29: warning: unused parameter 'argv'
make: *** [main_1mod_bim_plot-g.o] Error 1

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-09-23  4:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-22 19:50 Problem when using template as the base class? Peng Yu
2006-09-22 23:47 ` Peng Yu
2006-09-23  4:47   ` Daniel Llorens del Río

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).