Topic... just wondering if it would be friend or pointers in the main or something else...

Recommended Answers

All 4 Replies

For a complete answer, you need to provide a better description of what you're trying to do. What do you mean by "share"? If you just want a function to be visible, make it public. If you want multiple classes to see the same variable, the proper course of action depends on the circumstances.

Topic... just wondering if it would be friend or pointers in the main or something else...

It depends. Can you describe some program cases where you need to share (polysemantic term) variables?

well its in the api allegro, I want two public classes to share variables and use eachothers functions

Classes or (all) objects of these two classes?
Feel the difference...

The simplest way: there lots of global variables in Allegro environment. Add yet another or two ;)...

Seriously: explain use case(s) where you need so tight interrelations. May be it's ONE class splitted to these weird wrecks?..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.