Sunday, September 2, 2012

precedence of template over constructor


#include <iostream>

struct C{
};


struct D{
  D(const C&){}
};


struct A{
  template<typename T> void p(const T& t){
    std::cout<<"template "<<std::endl;
    }
 
  void p(const D& t){
    std::cout<<"constructor "<<std::endl;
  }
};



int main(){
  A a;
  C c;
  a.p(c);
}
=====OUTPUT=====
template

No comments:

Post a Comment