Problem when using template as the base class?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux