首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

class

使用

  • 类别声明范围枚举类型的声明%28自C++11%29
  • 范围枚举类型的声明

%28自C++11%29

  • 在...模板声明,,,class可以用来介绍类型模板参数和模板参数
  • 如果一个函数或变量存在于作用域中,其名称与类类型的名称相同,class可以添加到名称中以消除歧义,从而生成精化类型说明符

二次

代码语言:javascript
复制
class Foo;  // forward declaration of a class
 
class Bar { // definition of a class
  public:
    Bar(int i) : m_i(i) {}
  private:
    int m_i;
};
 
template <class T> // template argument
void qux() {
    T t;
}
 
int main()
{
    Bar Bar(1);
    class Bar Bar2(2); // elaborated type
}

二次

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券