c++ - C++ using 在类中意味着什么?

标签 c++ language-features using

在类定义中使用 using 是什么意思?

class myClass {
public:
  [...]
  using anotherClass::method;
};

最佳答案

该声明取消隐藏 基类成员。这最常用于允许成员函数的重载。示例:

class Base {
public:
   void method() const;
};

class Derived : public Base {
public:
   void method(int n) const;
   // Without the using, you would get compile errors on d.method();
   using Base::method;
};

关于c++ - C++ using 在类中意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5205105/

相关文章:

C++ std::map 运行超出范围

php - 交友网站算法

syntax - 在 lambda 中调用对象方法的 F# 简写

c# - 在 `using` 语句中内联创建的所有对象都将被释放吗?

c++ - 模板 : Deduction of array size failed

c++ - Eclipse 不解析 avcodec_send_packet()

c++ - 如果参数很复杂,* 和 & 运算符的作用是什么?

c# - 为什么我在使用 using 时会出现内存不足错误?

android - 使用 GestureDetectorCompat 的奇怪行为

c++ - 0xC0000005 : Access violation reading location 0x0000000000000000