Calling template methods in template classes

后端 未结 2 1209
夕颜
夕颜 2021-02-08 23:12

I\'m attempting to figure out why some code that I have won\'t compile and I done a fair bit of reduction an anonymizing to end up with this example:

#define NUL         


        
2条回答
  •  再見小時候
    2021-02-09 00:04

    In the context where you call

    return ap->amem();
    

    the name amem is a dependent name: If such a beast indeed refers to a member function template, you need to say so by adding the keyword template:

    return ap->template amem();
    

    BTW, note that you shall not define NULL! If you need a definition of the abomination you should include, e.g., cstddef. Best you use just 0 or nullptr when using C++ 2011.

提交回复
热议问题