C++ global extern “C” friend can't reach private member on namespaced class

前端 未结 3 2420
轻奢々
轻奢々 2021-02-20 14:46

Please consider the code:

#include    

using namespace std;

extern  \"C\"
void    foo( void );

namespace   A
{
    template< int No >
           


        
3条回答
  •  一生所求
    2021-02-20 15:12

    You need to declare the friend as extern "C". Your current friend declaration finds a friend foo in the global namespace that has C++ name mangling.

提交回复
热议问题