If I want to specialise just one method in a template, how do I do it?

前端 未结 4 1306
青春惊慌失措
青春惊慌失措 2020-11-30 09:54

Say I have a templated class like

template  struct Node
{
    // general method split
    void split()
    {
        // ... actual code her         


        
4条回答
  •  忘掉有多难
    2020-11-30 10:32

    Just define some

    template<>
    void Node::split()
    {
    }
    

    after the primary template, but before the first time you ever instantiate it.

提交回复
热议问题