資源簡介
C++實戰源碼-枚舉類型的定義與使用(入門級實例086).zip
代碼片段和文件信息
//?enum.cpp?:?Defines?the?entry?point?for?the?console?application.
//
#include?“stdafx.h“
#include?“iostream.h“
enum?Colors{redgreenblue};//定義枚舉類型
int?main(int?argc?char*?argv[])
{
Colors?col;//定義枚舉變量
int?c;
cin?>>?c;
col?=?(Colors)c;
switch?(col)
{
case?red:
cout?<“紅色\n“;
break;
case?green:
cout?<“綠色\n“;
break;
case?blue:
cout?<“藍色\n“;
break;
default:
break;
}
return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????467??2010-07-02?16:06??enum\enum.cpp
?????文件????????4512??2010-07-02?14:59??enum\enum.dsp
?????文件?????????533??2010-07-02?14:59??enum\enum.dsw
?????文件?????????291??2010-07-02?14:59??enum\StdAfx.cpp
?????文件?????????769??2010-07-02?14:59??enum\StdAfx.h
評論
共有 條評論