开发者

tempate function into a non-templated class?

开发者 https://www.devze.com 2023-02-04 19:51 出处:网络
I would like to add a \"templated function\" into a non-templated function like this : class A { template <class T>

I would like to add a "templated function" into a non-templated function like this :

class A
{
template <class T>
void Test<T>();
}

template <class T>
A::Test<T>();

But it tell me that I have an error in开发者_JAVA技巧 the .h file ! Is there a problem with this declaration ?

Remarks : my class MUST not be templated !

Thanks


You can define a member function template as follows:

class A
{
    template <typename T>
    void Test()
    {
        ...
    };
};
0

精彩评论

暂无评论...
验证码 换一张
取 消