Home > Software engineering >  Friend function for class in dll
Friend function for class in dll

Time:10-15

Lets say I have the following class in my dll

class Test { private: int x; };

and following function in client side application which uses my dll

void test();

Is there a way to make test function friend for Test class?

CodePudding user response:

Is there a way to make test function friend for Test class?

Yes, add a friend declaration to the class definition:

class Test {
private:
    int x;
    friend void test();
};
  • Related