yyyyyyyyyyyyyyyyyyyy

博客园 首页 新随笔 联系 订阅 管理

引用类中的enum

引用类中的enum,需要加类的域
class_name::value_in_enum_name

点击(此处)折叠或打开

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. class A{
  4.     public:
  5.     enum ee{
  6.         a = 0,
  7.         b,
  8.         max
  9.     };
  10. };
  11. class B{
  12.     public:
  13.     enum ee{
  14.         a = 1,
  15.         b,
  16.         max
  17.     };
  18. };
  19.     int
  20. main ( int argc, char *argv[] )
  21. {
  22.     printf("%d\n",A::max);
  23.     printf("%d\n",B::max);
  24. }

输出:
  2
  3

posted on 2015-09-04 12:38  xxxxxxxx1x2xxxxxxx  阅读(136)  评论(0编辑  收藏  举报