枚举常量及以常量为参数的成员函数,类似于ios定义

来源:百度文库 编辑:神马文学网 时间:2024/04/28 08:12:26
/*example one
#include
enum abc{Mon=1,Tue,Thirs,Wednes,Fri,Satur,Sun};//定义在类外class  OutTime{
public:
   static abc weekf;
 
};abc  OutTime::weekf=Mon;
void main(){
 cout<}
*/
/*example two
#include
enum abc{Mon=1,Tue,Thirs,Wednes,Fri,Satur,Sun};class  OutTime{
public:
   static abc weekf;
 
};abc  OutTime::weekf=Mon;
void main(){
 cout<}
*//*example three#include
enum abc{Mon=1,Tue,Thirs,Wednes,Fri,Satur,Sun};class  OutTime{
public:
  const abc weekf;
  OutTime():weekf(Mon){}
 
};//abc  OutTime::weekf=Mon;
void main(){
    OutTime OT;
 cout<}
*/
/*example four#include class  OutTime{
 
 enum abc{Mon=1,Tue,Thirs,Wednes,Fri,Satur,Sun};public:
   abc weekf;
   OutTime(){weekf=Mon;}
 
};  //OutTime::weekf=Mon;
void main(){
 OutTime OT;
 cout<}
*/
/*example five#include class  OutTime{
 
 enum abc{Mon=1,Tue,Thirs,Wednes,Fri,Satur,Sun};//定义在类中public:
   const abc weekf;
   OutTime():weekf(Mon){} 
};  //OutTime::weekf=Mon;
void main(){
 OutTime OT;
 cout<}*//*example six#include class  OutTime{
public: 
enum {Mon=1,Tue,Thirs,Wednes,Fri,Satur,Sun};//定义无名枚举类型   都是类中常量
 //output(enum a){
 //cout<<"the value is:"< //} 
};
void main(){
 //OutTime OT; cout<} */// example seven//类似ios类用法,定义枚举常量和以常量为参数的成员函数
#include class  OutTime{
public: 
enum {Mon=1,Tue,Thirs,Wednes,Fri,Satur,Sun};//定义无名枚举类型   都是类中常量
   void output(int a);
 
};void OutTime::output(int a){
  cout<<"the value is:"< }  void main(){
 
 OutTime OT; cout<}