草庐IT

showMeTheMoney

全部标签

c++ - 为什么不允许成员函数的模板特化?

如果我有一些琐碎的事情,例如(澄清一下,我并不是说这是一个很好的实现,只是一个演示成员函数部分模板特化失败的例子):templateclassBankAccount{Tmoney;UinterestRate;public:BankAccount(Tmoney,UinterestRate):money(money),interestRate(interestRate){}voidshowMeTheMoney();};我不能能够通过以下方式专门化每个功能://invalidcodetemplatevoidBankAccount::showMeTheMoney(){printf("$%d.0