moje pytanie jest podobne do tego: How to publicly inherit from a base class but make some of public methods from the base class private in the derived class?, ale moja sprawa jest nieco bardziej skomplikowana, ponieważ chcę, aby zmienić dostęp dla przeciążonych funkcji/Szablon:C++ zmienić dostęp do funkcji składowej z przeciążenia
template<typename T>
class Base
{
public:
void fun(int); //1
void fun(float); //2
void fun(T); //3
template<typename U> //4
void fun(U);
};
template<typename T1, typename T2>
class Derived : private Base<T1>
{
public:
//change access specifier here for:
//1 - make fun(int) available
//2 - fun(float) is really evil and it should not be accessible!
//3 - make fun(T1) == Base::fun(T) available
//4 - make template<typename U> void Base::fun(U) available
};
I Wcześniej próbowałem metody z poprzedniej odpowiedzi, aby pewne funkcje publiczne, ale pojawia się ten błąd:
ISO C++11 does not allow access declarations; use using declarations instead
Jak mogę używać using
aby tylko wybrane funkcje (1, 3 i 4), dostępny dla użytkowników Derived
?
+1 Uwielbiam, gdy OP wychodzi z najlepszą odpowiedzią! –