c++11 - C++ change access for member function with overloading -
my question related one: how publicly inherit base of operations class create of public methods base of operations class private in derived class?, case little more complex want alter access overloaded/template functions:
template<typename t> class base of operations { 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 - create fun(int) available //2 - fun(float) evil , should not accessible! //3 - create fun(t1) == base::fun(t) available //4 - create template<typename u> void base::fun(u) available };
i've tried method previous reply create function public, error:
iso c++11 not allow access declarations; utilize using declarations instead
how can utilize using
create selected functions (1, 3 , 4) available users of derived
?
as armen , jarod pointed out, using
bring fun
's in derived class. jarod though had great idea: delete
evil function! combining answers got this:
template<typename t1, typename t2> class derived : private base<t1> { public: using base<t1>::fun; void fun(float) = delete; };
which wanted originally!
c++ c++11 c++14
No comments:
Post a Comment