• 定义文件的结构


    定义文件有三部分内容:

    (1) 定义文件开头处的版权和版本声明。

    (2) 对一些头文件的引用。

    (3) 程序的实现体(包括数据和代码)。

     1 #include <iostream>
     2 
     3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
     4 using namespace std;
     5 int main(int argc, char** argv) {
     6     //定义枚举类型,并指定其枚举元素的值
     7     enum color {  
     8          RED=3,
     9          YELLOW=6,
    10          BLUE=9
    11     };
    12 
    13     //声明枚举变量a和b,并为枚举变量a赋初值 
    14     enum color a=RED;
    15     color b;        //合法,与C语言不同
    16 
    17     // 输出枚举常量 
    18     cout<<"RED="<<RED<<endl;
    19     cout<<"YELLOW="<<YELLOW<<endl;
    20     cout<<"BLUE="<<BLUE<<endl;
    21     
    22     //枚举变量的赋值和输出
    23     b=a;
    24     a=BLUE;
    25     cout<<"a="<<a<<endl;
    26     cout<<"b="<<b<<endl;
    27     //a=100;   错误!
    28     //a=6      也错误!
    29 
    30     //枚举变量的关系运算
    31     b=BLUE;                            // 枚举变量的赋值运算
    32     cout<<"a<b="<<(a<b)<<endl;
    33     return 0;
    34 }
  • 相关阅读:
    Django内置Admin解析
    python项目 配置文件 的设置
    Django---信号
    bash配置文件
    week4 作业
    shell基础练习题
    shell基础
    shell变量与运算
    week3 作业
    文件权限管理
  • 原文地址:https://www.cnblogs.com/borter/p/9406002.html
Copyright © 2020-2023  润新知