2020国产成人精品视频,性做久久久久久久久,亚洲国产成人久久综合一区,亚洲影院天堂中文av色

分享

#ifdef的用法

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

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

更一般的情況是,#define語(yǔ)句是包含在一個(gè)特定的頭文件中。
比如,新建頭文件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;
}
運(yùn)行結(jié)果如下:Beginning execution of main()
                        Press any key to continue 
結(jié)論:通過(guò)使用#ifdef指示符,我們可以區(qū)隔一些與特定頭文件、程序庫(kù)和其他文件版本有關(guān)的代碼。

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

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多