function template application in class

#include
#include
using namespace std;

class ConfigTest
{
public:
 ConfigTest()
 {
  std::cout<<"Config constructor...."<  }
 template
 T value( std::string key, T fallback ) const {
  std::string r = "feier";
  return r;
 }
 template
 T getIfSet( std::string key, T output ) const {
  if ( key == "haces" ) {
   T cc = value(key, output);
   return cc;
  }
  return false;
 }
};
void main()
{
 /** the follow line is error!  this is not class template,but function template in class*/
 //Config testConfig;
 ConfigTest testConfig;
 std::string in = "haces";
 std::string outputStr = "qq";
 std::string testBool = testConfig.getIfSet(in,outputStr);
 std::cout<  system("pause");
}

你可能感兴趣的:(function template application in class)