This question has already been asked here -- more than twice, actually --, but I myself haven't been able to derive a solution to my problem from the posts.
What I have is a library, with, among others, a class named A
in it. From class A
I need to access an std::map<>
, but it is private. Also, and based on the possibilities I found in the post I mentioned, class A
has no templated function.
I'm actually able to recompile the library, so that I could simply change the visibility. However, that would be a lot of work -- and I'm not sure if changing the visibility won't get anything else to crash.
What I'd like to do is, in a class B
:
// NOT MY CODE -- library <a.h>
class A {
private:
std::map<int, int> A_map;
};
// MY CODE -- module "b.h"
# include <a.h>
class B : private A {
public:
B() {
for (auto it(A_map.begin()); it != A_map.end(); ++it) {
...;
}
}
};
How may I do it without changing the original class -- and without having any available templated method in the base class for to be overloaded/specialized?