I guess I've fallen into a situation that I need to modify something that is "protected" in some sense. I worked around and didn't find a proper solution, or it is actually unsolvable.
A.h
class A
{
static void append(int x);
}
A.cpp
class B;
static B *queue = 0;
class B
{
friend class A;
int value;
B* next;
B(int x)
{
value = x;
next = queue;
queue = this;
}
}
void A::append(int x)
{
new B(x);
}
What I want to do is basically finding a way to manipulate the queue externally in another source file without changing A.h and A.cpp, since class A and B don't provide methods to manipulate the queue.
C.cpp
#include "A.h"
<whatever magic declaration>
void C()
{
queue = 0;
}
Thank you very much for any comments!