小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

#ifdef的用法

 Frank_Chia 2009-07-27
#ifdef的用法
 
        靈活使用#ifdef指示符,我們可以區(qū)隔一些與特定頭文件、程序庫和其他文件版本有關的代碼。
代碼舉例:新建define.cpp文件

#include "iostream.h"
int main()
{
#ifdef DEBUG      
cout<< "Beginning execution of main()";
#endif      
return 0;
}
運行結果為:Press any key to continue
 
改寫代碼如下:
#include "iostream.h"
#define DEBUG
int main()
{
#ifdef DEBUG      
cout<< "Beginning execution of main()";
#endif       
return 0;
}
運行結果為:Beginning execution of main()
                     Press any key to continue

更一般的情況是,#define語句是包含在一個特定的頭文件中。
比如,新建頭文件head.h,在文件中加入代碼:

#ifndef DEBUG
#define DEBUG
#endif

而在define.cpp源文件中,代碼修改如下:
#include "iostream.h"
#include "head.h" 
int main(){
#ifdef DEBUG      
cout<< "Beginning execution of main()";
#endif       
return 0;
}
運行結果如下:Beginning execution of main()
                        Press any key to continue 
結論:通過使用#ifdef指示符,我們可以區(qū)隔一些與特定頭文件、程序庫和其他文件版本有關的代碼。

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多