简体   繁体   中英

tempate function into a non-templated class?

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 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()
    {
        ...
    };
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM