How to call a private function via friend function?

后端 未结 1 354
盖世英雄少女心
盖世英雄少女心 2021-01-21 02:59

Hello I am trying to access a private member function is Gtest. The code looks somewhat similar to this. So, how can I access static void Pri_fun?

1条回答
  •  庸人自扰
    2021-01-21 03:29

    Since it's a static function, you should access it via the class name:

    abc::Pri_fun();
    

    You should make a caller function though, or call it from the friend class' constructor:

    class test{
    public:
        void foo() 
        {
            abc::Pri_fun();
        }
    };
    

    or

    class test{
    public:
        test() 
        {
            abc::Pri_fun();
        }
    };
    

    0 讨论(0)
提交回复
热议问题