C++ using声明能否区分重载函数?
我想做一些类似的事情:C++ using声明能否区分重载函数?,c++,C++,我想做一些类似的事情: struct Base{ private: int x_; public: Base& x(int x) { x_=x; return *this; } int x() const { return x_; } }; struct Derived : private Base { public: using Base::x; //just the getter? private: using Base::x; //the setter };
struct Base{
private:
int x_;
public:
Base& x(int x) { x_=x; return *this; }
int x() const { return x_; }
};
struct Derived : private Base {
public:
using Base::x; //just the getter?
private:
using Base::x; //the setter
};
使用声明会引入名称,而不是重载。重载是指使用相同的名称来表示多个事物。所以不是。使用声明会引入名称,而不是重载。重载是指使用相同的名称来表示多个事物。所以没有。