C++警告C4482的解决方式

在enum类型外,加上命名空间就可以解决问题。

#include <iostream>

namespace ns
{
	enum Weekday
	{
		mon,
		tue,
		wed,
		thu,
		fri,
		sat,
		sun
	};
};

int main()
{
	// 定义一个变量表示一周中的某一天,并将其初始佳设置为星期天
	ns::Weekday nDay = ns::sun;
	std::cout << nDay << std::endl;
	return 0;
}


 

你可能感兴趣的:(C++,c,sun)