Suppose we have a class function like so:
class foo {
// Private data needs to be accessed by bar
public:
static int bar();
};
int main(int argc, char** argv) {
// Want to write bar() instead of foo::bar()
bar();
}
using doesn’t seem to work for importing a class member into global scope, and if bar is made a global function it won’t be able to access private data. Is there a way bar can be made accessible in global scope by the unqualified name?
That’s what
friends are for.