Can 2 classes share a friend function?

后端 未结 4 758
轻奢々
轻奢々 2021-01-12 12:05

Today i have a doubt regarding friend function. Can two classes have same friend function? Say example friend void f1(); declared in class A and class B. Is t

4条回答
  •  走了就别回头了
    2021-01-12 12:58

    #include
    
    using namespace std;
    
    class first
    {
        friend void getdata(first object1, int i);
    };
    
    class second
    {
        friend void getdata(second object2, int j);
    };
    
    getdata(first object1, int i, second object2, int j)
    {
        cout<

提交回复
热议问题