tom_usenet said:
The best way to do it is to make the class you want to access the
function a friend - note that you can do this even if the class in
question is in a library. Adding a friend declaration to a class
doesn't require it to be recompiled.
AFAIK, that is undefined
If you can't modify the header for some reason, then the usual
technique is to add:
#define private public
before including the header. Obviously this doesn't work if the
function is at the top of the class, before any private:.
ehm.. ever heard of the ONE-definition rule?
If you don't have the source of a library, don't change the headers that
come with it, and don't try to get access to members the authors didn't
want you to have access to: you might be breaking invariants without
knowing it.
If you do have access to the sources, make sure you don't break anything
by accessing the private members you're accessing and/or add accessors
and mutators to the class that keep the invariants in tact - consult
with the original author if you can and document your interpretation of
the class' invariants in case you break any you hadn't found/didn't know
about.
rlc