Jump to content
  • Advertisement
Sign in to follow this  
BloodLust666

friend function

This topic is 4838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok, i have a function (or rather a specific char value) that is returned by a function that i want to be visible to other classes and just that one function and char data only. how would i do that?

Share this post


Link to post
Share on other sites
Advertisement
If its a function, you can either declare it as a public function so that all classes can access it (I prefer this), or if you only want specific classes to be able to use it, make it private/protected and declare those special classes as friends within the function-bearing class.

class piepiepie {
public:
void anyoneCanCall();

protected:
void itsASecretOneOneOne();

friend caekcaek;
friend piepie; // liek omg we can see the secret oneoneone
};

Share this post


Link to post
Share on other sites
well, thing is, i only have one object of the class that has the friend data/function and i want that same data to be visible in other classes

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!