#include <iostream>
#include <stdio.h>
using namespace std;
namespace bug
{
enum month1 { January = 1, February = 2 };
enum month2 { January2 = 3, February2 = 4 };
class bug1
{
public:
enum month { January, February };
bug1()
{
a = 10;
}
private:
int a;
friend void print(bug1& t);
};
void print(bug1& t)
{
cout << t.a << endl;
}
}
int main(void)
{
bug::month1 t = bug::January;
bug::month2 t1 = bug::January2; //not like that, bug::month2::January2
cout << (int)t << ' ' << (int)t1 << endl;
//in C laguage, compare with C++ language , you will know
enum fruit {apple,orange};
fruit f1;
f1=apple; //here
printf("enum f1=%d\n",f1);
return 0;
}
C++ enum and namespace
最新推荐文章于 2024-06-21 08:30:17 发布