[C++]Partly Specialize member function in Class Templates

It is allowed, however, you can no longer to use un-specialized member function.
using namespace std;

template
<typename T>
class myTemplate
{
public:
void Foo1(){cout<<"Foo1"<<endl;}
void Foo2(){cout<<"Foo2"<<endl;}
};

template
<>
class myTemplate<float>
{
public:
void Foo1(){cout<<"Float Foo1"<<endl;}

};

int main()
{
myTemplate
<int> i;
i.Foo1();
i.Foo2();
myTemplate
<float> f;
f.Foo1();
//f.Foo2(); //error C2039: 'Foo2' : is not a member of 'myTemplate<float>'
return 10;
}
posted @ 2011-07-04 12:17  嗷嗷  阅读(210)  评论(1编辑  收藏  举报