Error with using decltype() in C++11 (creating opaque error message in gcc 4.7.0)

后端 未结 5 2480
别那么骄傲
别那么骄傲 2021-02-19 09:55

with the following code (a boiled-down version of my original code)

#include 
#include 

template  class A;                   


        
5条回答
  •  庸人自扰
    2021-02-19 10:56

    Your function auto diff(A const& y) access the private variable A::a from outside the class in your decltype statement.

    Your A::a should be public if you want to use it the way you do in your diff function.

    EDIT: it seems the friendship solution is much better suited for this problem, then just making it public.

提交回复
热议问题