Skip to main content
gamedev.net
🔒 Locked

Multiple Friend Function

Started by CyberSlag5k 1 reply 300+ views
Original Post
CyberSlag5k
CyberSlag5k
How can I make a c++ function a friend to more than one class? When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...
Without order nothing can exist - without chaos nothing can evolve.
Sneftel
Sneftel
Any class where you make the friend declaration will be a friend to that function. Watch:


class A
{
friend void foo();
};

class B
{
friend void foo();
};

void foo()
{
...
}

Now foo() can access the private members of A and B.


"Sneftel is correct, if rather vulgar." --Flarelocke
CyberSlag5k
CyberSlag5k
I thought it might be something ilke that. Thanks alot

When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...
Without order nothing can exist - without chaos nothing can evolve.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.