Re: Problem when using template as the base class?

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

 



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 <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"].template 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();
}

[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