Is there any difference if we define friend function inside or outside of class

前端 未结 6 1305
借酒劲吻你
借酒劲吻你 2020-12-10 16:09

What is the difference between defining friend function inside the class or declaring inside and define outside of the class. Also why it is possible to place definition ins

6条回答
  •  既然无缘
    2020-12-10 16:30

    A function can be defined in a friend declaration of a class if and only if the class is a non-local class , the function name is unqualified, and the function has namespace scope. Such a function is implicitly inline. A friend function defined in a class is in the (lexical) scope of the class in which it is defined. A friend function defined outside the class is not .

    C++11, [class.friend], ¶6-7

提交回复
热议问题