Dependent scope and nested templates

前端 未结 2 1697
傲寒
傲寒 2020-12-02 19:08

When I compile this:

#ifndef BTREE_H
#define BTREE_H
#include 

template 
class btree
{
public:
    class node
    {
         


        
2条回答
  •  情话喂你
    2020-12-02 20:01

    The C++ grammar is horrendous, and as such it is not possible, when given a template class, to know whether the ::node you refer to is a variable/constant or a type.

    The Standard therefore mandates that you use typename before types to remove this ambiguity, and treats all other usages as if it was a variable.

    Thus

    template 
    typename btree::node* btree::findLead(T const& value)
    ^~~~~~~~
    

    is the correct signature for the definition.

提交回复
热议问题