Hi,
I am playing with metaprogramming. I have this problem:

template<bool f>
class A
{
    public:
        void P()
        {
             cout << "f = true" << endl;
        }

        void Q()
        {
             cout << "Q" << endl;
        }
};

template<>
class A<false>
{
    public:
        void P()
        {
             cout << "f = false" << endl;
        }

        void Q()
        {
             cout << "Q" << endl;
        }
};

because The Q function is not changed, I would prefer not to write it again in A<false>. Is there any way to do that?

Haven't done template programming in a while, but as far as I remember you only need to specialise a function rather than the entire class. I think this should work, if not it should give you a good idea how to do what you want...

template <typename ty>
class thing {
public:
  void one();

};

template<typename ty>
void thing<ty>::one() {
  std::cout<< "thing<ty>::one() called...\n";
}

template<>
void thing<bool>::one() {
  std::cout<< "thing<bool>::one() called...\n";
}

int main( void ) {
  thing<bool> boolThing;
  thing<int> intThing;

  boolThing.one();
  intThing.one();

  return 0;
}