Private inheritance and exposing a functionality

I've got 2 classes :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class B
{
public:
	int pubB;

	int getPub();

};

class C : private B
{
public:
	B::getPub;
	
	int getPub();
	int pubC;
};


Is there any way to access the exposed B::getPub function ?
As C has its own getPub, writing
1
2
C oC;
C.getPub();


results in callung the C version of getPub, while
1
2
C oC;
C.B::getPub();


results in an error as the whole B class is private in that context.

I know that I could acces B::getPub() if there was no redefined version of getPub in C class, but I'm wondering if theres anything I could do to access it without changing the classes code ?
Not that way, as you expressed explicit intent to hide that overload of getPub
You can provide another access function which will wrap B::getPub calls.
Last edited on
Ok, thank you
Topic archived. No new replies allowed.