荣耀彩票代理

  • 热门专题

关于C++里的文件以及源文件相关简述

作者:whl  发布日期:2018-12-26 08:57:00
  •   说到C++估计没有人不知道的吧?这款编写程序的编程语言的出现可以说为我们提供了很多的方便,很多我们在使用的程序都是用它编写出来的。下面小编就给大家详细介绍一下关于C++语言里的文件以及源文件的一些相关知识的介绍,想要学习更多的朋友不妨跟着小编一起继续学习一番。

      C++ZHONGDETOUWENJIANHEYUANWENJIANXIANGJIE

    荣耀彩票代理  YI、C++BIANYIMOSHI

    荣耀彩票代理  TONGCHANG,ZAIYIGEC++CHENGXUZHONG,ZHIBAOHANLIANGLEIWENJIAN——.cppWENJIANHE.hWENJIAN。QIZHONG,.cppWENJIANBEICHENGZUOC++YUANWENJIAN,LIMIANFANGDEDOUSHIC++DEYUANDAIMA;ER.hWENJIANZEBEICHENGZUOC++TOUWENJIAN,LIMIANFANGDEYESHIC++DEYUANDAIMA。

      C+ +YUYANZHICHI“FENBIEBIANYI”(separate compilation)。YEJIUSHISHUO,YIGECHENGXUSUOYOUDENEIRONG,KEYIFENCHENGBUTONGDEBUFENFENBIEFANGZAIBUTONGDE.cppWENJIANLI。.cppWENJIANLIDEDONGXIDOUSHIXIANGDUIDULIDE,ZAIBIAN YI(compile)SHIBUXUYAOYUQITAWENJIANHUTONG,ZHIXUYAOZAIBIANYICHENGMUBIAOWENJIANHOUZAIYUQITADEMUBIAOWENJIANZUOYICILIANJIE(link)JIUXINGLE。BIRU,ZAIWENJIANa.cppZHONGDINGYI LEYIGEQUANJUHANSHU“void a() {}”,ERZAIWENJIANb.cppZHONGXUYAODIAOYONGZHEIGEHANSHU。JISHIZHEIYANG,WENJIANa.cppHEWENJIANb.cppBINGBUXUYAOXIANGHUZHIDAODUIFANGDECUNZAI,ERSHIKEYIFENBIEDIDUITAMENJINXINGBIANYI, BIANYICHENGMUBIAOWENJIANZHIHOUZAILIANJIE,ZHENGGECHENGXUJIUKEYIYUNXINGLE。

      ZHEISHIZENMESHIXIANDENI?CONGXIECHENGXUDEJIAODULAIJIANG,HENJIANDAN。ZAIWENJIANb.cppZHONG,ZAIDIAOYONG “void a()”HANSHUZHIQIAN,XIANSHENGMINGYIXIAZHEIGEHANSHU“void a();”,JIUKEYILE。ZHEISHIYINWEIBIANYIQIZAIBIANYIb.cppDESHIHOUHUISHENGCHENGYIGEFUHAOBIAO(symbol table),XIANG“void a()”ZHEIYANGDEKANBUDAODINGYIDEFUHAO,JIUHUIBEICUNFANGZAIZHEIGEBIAOZHONG。ZAIJINXINGLIANJIEDESHIHOU,BIANYIQIJIUHUIZAIBIEDEMUBIAOWENJIANZHONGQUXUNZHAOZHEIGEFUHAODEDINGYI。YIDANZHAODAOLE,CHENGXUYEJIUKEYI SHUNLIDISHENGCHENGLE。

      ZHUYIZHEILITIDAOLELIANGGEGAINIAN,YIGESHI“DINGYI”,YIGESHI“SHENGMING”。JIANDANDISHUO,“DINGYI”JIUSHIBAYIGEFUHAOWANWANZHENGZHENGDIMIAOSHUCHULAI:TASHIBIAN LIANGHAISHIHANSHU,FANHUISHENMELEIXING,XUYAOSHENMECANSHUDENGDENG。ER“SHENGMING”ZEZHISHISHENGMINGZHEIGEFUHAODECUNZAI,JIGAOSUBIANYIQI,ZHEIGEFUHAOSHIZAIQITAWENJIANZHONGDINGYIDE,WOZHEILIXIANYONGZHE,NILIANJIE DESHIHOUZAIDAOBIEDEDIFANGQUZHAOZHAOKANTADAODISHISHENMEBA。DINGYIDESHIHOUYAOANC++YUFAWANZHENGDIDINGYIYIGEFUHAO(BIANLIANGHUOZHEHANSHU),ERSHENGMINGDESHIHOUJIUZHIXUYAOXIECHUZHEIGEFUHAODEYUANXINGLE。 XUYAOZHUYIDESHI,YIGEFUHAO,ZAIZHENGGECHENGXUZHONGKEYIBEISHENGMINGDUOCI,DANQUEYAOQIEJINYAOBEIDINGYIYICI。SHIXIANG,RUGUOYIGEFUHAOCHUXIANLELIANGZHONGBUTONGDEDINGYI,BIANYIQIGAITINGSHEIDE?

    荣耀彩票代理  ZHEI ZHONGJIZHIJIC++CHENGXUYUANMENDAILAILEHENDUOHAOCHU,TONGSHIYEYINCHULEYIZHONGBIANXIECHENGXUDEFANGFA。KAOLVYIXIA,RUGUOYOUYIGEHENCHANGYONGDEHANSHU“void f() {}”,ZAIZHENGGECHENGXUZHONGDEXUDUO.cppWENJIANZHONGDOUHUIBEIDIAOYONG,NEIME,WOMENJIUZHIXUYAOZAIYIGEWENJIANZHONGDINGYIZHEIGEHANSHU,ERZAIQITADEWENJIANZHONGSHENGMINGZHEIGEHANSHUJIUKEYILE。YIGEHANSHUHAI HAODUIFU,SHENGMINGQILAIYEJIUYIJUHUA。DANSHI,RUGUOHANSHUDUOLE,BIRUSHIYIDADUIDESHUXUEHANSHU,YOUHAOJIBAIGE,NEIZENMEBAN?NENGBAOZHENGMEIGECHENGXUYUANDOUKEYIWANWANQUANQUANDIBASUOYOUHANSHUDEXINGSHIDOU ZHUNQUEDIJIXIALAIBINGXIECHULAIMA?

      ER、SHENMESHITOUWENJIAN

      HENXIANRAN,DAANSHIBUKENENG。DANSHIYOUYIGEHENJIANDANDIBANFA,KEYIBANGZHUCHENGXUYUANMENSHENGQUJIZHUNEIMEDUOHANSHUYUANXINGDEMAFAN:WOMENKEYIBANEIJIBAIGEHANSHUDESHENGMINGYUJUQUANDOUXIANXIEHAO,FANGZAIYIGEWENJIANLI,DENGDAOCHENGXUYUANXUYAOTAMENDESHIHOU,JIUBAZHEIXIEDONGXIQUANBUcopyJINTADEYUANDAIMAZHONG。

    荣耀彩票代理  ZHEI GEFANGFAGURANKEXING,DANHAISHITAIMAFAN,ERQIEHAIXIANDEHENBENZHUO。YUSHI,TOUWENJIANBIANKEYIFAHUITADEZUOYONGLE。SUOWEIDETOUWENJIAN,QISHITADENEIRONGGEN.cppWENJIANZHONGDENEIRONGSHIYIYANGDE,DOUSHI C++DEYUANDAIMA。DANTOUWENJIANBUYONGBEIBIANYI。WOMENBASUOYOUDEHANSHUSHENGMINGQUANBUFANGJINYIGETOUWENJIANZHONG,DANGMOUYIGE.cppYUANWENJIANXUYAOTAMENSHI,TAMENJIUKEYITONGGUOYIGEHONGMINGLING “#include”BAOHANJINZHEIGE.cppWENJIANZHONG,CONGERBATAMENDENEIRONGHEBINGDAO.cppWENJIANZHONGQU。DANG.cppWENJIANBEIBIANYISHI,ZHEIXIEBEIBAOHANJINQUDE.hWENJIANDEZUOYONGBIANFA HUILE。

    荣耀彩票代理  JUYIGELIZIBA,JIASHESUOYOUDESHUXUEHANSHUZHIYOULIANGGE:f1HEf2,NEIMEWOMENBATAMENDEDINGYIFANGZAImath.cppLI:

    定义放在math.cpp

      BINGBA“ZHEIXIE”HANSHUDESHENGMINGFANGZAIYIGETOUWENJIANmath.hZHONG:

    头文件math.h

      ZAILINGYIGEWENJIANmain.cppZHONG,WOYAODIAOYONGZHEILIANGGEHANSHU,NEIMEJIUZHIXUYAOBATOUWENJIANBAOHANJINLAI:

    头文件包含进来

      ZHEI YANG,BIANSHIYIGEWANZHENGDECHENGXULE。XUYAOZHUYIDESHI,.hWENJIANBUYONGXIEZAIBIANYIQIDEMINGLINGZHIHOU,DANTABIXUYAOZAIBIANYIQIZHAODEDAODEDIFANG(BIRUGENmain.cppZAIYIGEMULUXIA)。 main.cppHEmath.cppDOUKEYIFENBIETONGGUOBIANYI,SHENGCHENGmain.oHEmath.o,RANHOUZAIBAZHEILIANGGEMUBIAOWENJIANJINXINGLIANJIE,CHENGXUJIUKEYIYUNXINGLE。

      SAN、#include

      #include SHIYIGELAIZICYUYANDEHONGMINGLING,TAZAIBIANYIQIJINXINGBIANYIZHIQIAN,JIZAIYUBIANYIDESHIHOUJIUHUIQIZUOYONG。#includeDEZUOYONGSHIBATAHOUMIANSUOXIEDENEIGEWENJIANDENEIRONG,WANWANZHENGZHENGDI、 YIZIBUGAIDIBAOHANDAODANGQIANDEWENJIANZHONGLAI。ZHIDEYITIDESHI,TABENSHENSHIMEIYOUQITARENHEZUOYONGYUFUGONGNENGDE,TADEZUOYONGJIUSHIBAMEIYIGETACHUXIANDEDIFANG,TIHUANCHENGTAHOUMIANSUOXIEDENEIGEWENJIANDE NEIRONG。JIANDANDEWENBENTIHUAN,BIEWUQITA。YINCI,main.cppWENJIANZHONGDEDIYIJU(#include "math.h"),ZAIBIANYIZHIQIANJIUHUIBEITIHUANCHENGmath.hWENJIANDENEIRONG。JIZAIBIANYIGUOCHENGJIANGYAOKAISHIDESHIHOU,main.cppDENEIRONGYIJINGFASHENGLEGAIBIAN:

    main.cpp的内容

      BUDUOBUSHAO,GANGGANGHAO。TONGLIKEZHI,RUGUOWOMENCHULEmain.cppYIWAI,HAIYOUQITADEHENDUO.cppWENJIANYEYONGDAOLEf1HEf2HANSHUDEHUA,NEIMETAMENYETONGTONGZHIXUYAOZAISHIYONGZHEILIANGGEHANSHUQIANXIESHANGYIJU#include "math.h"JIUXINGLE。

    荣耀彩票代理  SI、TOUWENJIANZHONGYINGGAIXIESHENME

      TONG GUOSHANGMIANDETAOLUN,WOMENKEYILEJIEDAO,TOUWENJIANDEZUOYONGJIUSHIBEIQITADE.cppBAOHANJINQUDE。TAMENBENSHENBINGBUCANYUBIANYI,DANSHIJISHANG,TAMENDENEIRONGQUEZAIDUOGE.cppWENJIANZHONGDEDAOLE BIANYI。TONGGUO“DINGYIZHINENGYOUYICI”DEGUIZE,WOMENHENRONGYIKEYIDECHU,TOUWENJIANZHONGYINGGAIZHIFANGBIANLIANGHEHANSHUDESHENGMING,ERBUNENGFANGTAMENDEDINGYI。YINWEIYIGETOUWENJIANDENEIRONGSHIJISHANGSHIHUIBEIYIN RUDAODUOGEBUTONGDE.cppWENJIANZHONGDE,BINGQIETAMENDOUHUIBEIBIANYI。FANGSHENGMINGDANGRANMEISHI,RUGUOFANGLEDINGYI,NEIMEYEJIUXIANGDANGYUZAIDUOGEWENJIANZHONGCHUXIANLEDUIYUYIGEFUHAO(BIANLIANGHUOHANSHU)DEDING YI,ZONGRANZHEIXIEDINGYIDOUSHIXIANGTONGDE,DANDUIYUBIANYIQILAISHUO,ZHEIYANGZUOBUHEFA。

      SUOYI,YINGGAIJIZHUDEYIDIANJIUSHI,.hTOUWENJIANZHONG,ZHINENGCUNZAIBIANLIANGHUOZHEHANSHUDESHENGMING, ERBUYAOFANGDINGYI。JI,ZHINENGZAITOUWENJIANZHONGXIEXINGRU:extern int a;HEvoid f();DEJUZI。ZHEIXIECAISHISHENGMING。RUGUOXIESHANGint a;HUOZHEvoid f() {}ZHEIYANGDEJUZI,NEIMEYIDANZHEIGETOUWENJIANBEILIANGGEHUOLIANGGEYISHANGDE.cppWENJIANBAOHANDEHUA,BIANYIQIHUILIMABAOCUO。(GUANYUextern,QIANMIANYOUTAOLUNGUO,ZHEILIBUZAITAOLUNDINGYIGEN SHENGMINGDEQUBIELE。)DANSHI,ZHEIGEGUIZESHIYOUSANGELIWAIDE。

    荣耀彩票代理  YI,TOUWENJIANZHONGKEYIXIEconstDUIXIANGDEDINGYI。YINWEIQUANJUDEconstDUIXIANGMO RENSHIMEIYOUexternDESHENGMINGDE,SUOYITAZHIZAIDANGQIANWENJIANZHONGYOUXIAO。BAZHEIYANGDEDUIXIANGXIEJINTOUWENJIANZHONG,JISHITABEIBAOHANDAOQITADUOGE.cppWENJIANZHONG,ZHEIGEDUIXIANGYEDOUZHIZAIBAOHANTADE NEIGEWENJIANZHONGYOUXIAO,DUIQITAWENJIANLAISHUOSHIBUKEJIANDE,SUOYIBIANBUHUIDAOZHIDUOZHONGDINGYI。TONGSHI,YINWEIZHEIXIE.cppWENJIANZHONGDEGAIDUIXIANGDOUSHICONGYIGETOUWENJIANZHONGBAOHANJINQUDE,ZHEIYANGYEJIUBAOZHENG LEZHEIXIE.cppWENJIANZHONGDEZHEIGEconstDUIXIANGDEZHISHIXIANGTONGDE,KEWEIYIJULIANGDE。TONGLI,staticDUIXIANGDEDINGYIYEKEYIFANGJINTOUWENJIAN。

      ER,TOUWENJIANZHONGKE YIXIENEILIANHANSHU(inline)DEDINGYI。YINWEIinlineHANSHUSHIXUYAOBIANYIQIZAIYUDAOTADEDIFANGGENJUTADEDINGYIBATANEILIANZHANKAIDE,ERBINGFEISHIPUTONGHANSHUNEIYANGKEYIXIANSHENGMINGZAILIAN JIEDE(NEILIANHANSHUBUHUILIANJIE),SUOYIBIANYIQIJIUXUYAOZAIBIANYISHIKANDAONEILIANHANSHUDEWANZHENGDINGYICAIXING。RUGUONEILIANHANSHUXIANGPUTONGHANSHUYIYANGZHINENGDINGYIYICIDEHUA,ZHEISHIERJIUNANBANLE。YINWEIZAI YIGEWENJIANZHONGHAIHAO,WOKEYIBANEILIANHANSHUDEDINGYIXIEZAIZUIKAISHI,ZHEIYANGKEYIBAOZHENGHOUMIANSHIYONGDESHIHOUDOUKEYIJIANDAODINGYI;DANSHI,RUGUOWOZAIQITADEWENJIANZHONGHAISHIYONGDAOLEZHEIGEHANSHUNEIZENMEBAN NI?ZHEIJIHUMEISHENMETAIHAODEJIEJUEBANFA,YINCIC++GUIDING,NEILIANHANSHUKEYIZAICHENGXUZHONGDINGYIDUOCI,ZHIYAONEILIANHANSHUZAIYIGE.cppWENJIANZHONGZHICHUXIANYICI,BINGQIEZAISUOYOUDE.cppWEN JIANZHONG,ZHEIGENEILIANHANSHUDEDINGYISHIYIYANGDE,JIUNENGTONGGUOBIANYI。NEIMEXIANRAN,BANEILIANHANSHUDEDINGYIFANGJINYIGETOUWENJIANZHONGSHIFEICHANGMINGZHIDEZUOFA。

    荣耀彩票代理  SAN,TOUWENJIANZHONGKEYIXIELEI (class)DEDINGYI。YINWEIZAICHENGXUZHONGCHUANGJIANYIGELEIDEDUIXIANGSHI,BIANYIQIZHIYOUZAIZHEIGELEIDEDINGYIWANQUANKEJIANDEQINGKUANGXIA,CAINENGZHIDAOZHEIGELEIDEDUIXIANGYINGGAIRUHEBUJU,SUOYI,GUANYULEIDE DINGYIDEYAOQIU,GENNEILIANHANSHUSHIJIBENYIYANGDE。SUOYIBALEIDEDINGYIFANGJINTOUWENJIAN,ZAISHIYONGDAOZHEIGELEIDE.cppWENJIANZHONGQUBAOHANZHEIGETOUWENJIAN,SHIYIGEHENHAODEZUOFA。ZAIZHEILI,ZHIDEYITI DESHI,LEIDEDINGYIZHONGBAOHANZHESHUJUCHENGYUANHEHANSHUCHENGYUAN。SHUJUCHENGYUANSHIYAODENGDAOJUTIDEDUIXIANGBEICHUANGJIANSHICAIHUIBEIDINGYI(FENPEIKONGJIAN),DANHANSHUCHENGYUANQUESHIXUYAOZAIYIKAISHIJIUBEIDINGYIDE,ZHEIYEJIU SHIWOMENTONGCHANGSUOSHUODELEIDESHIXIAN。YIBAN,WOMENDEZUOFASHI,BALEIDEDINGYIFANGZAITOUWENJIANZHONG,ERBAHANSHUCHENGYUANDESHIXIANDAIMAFANGZAIYIGE.cppWENJIANZHONG。ZHEISHIKEYIDE,YESHIHENHAODEBANFA。 BUGUO,HAIYOULINGYIZHONGBANFA。NEIJIUSHIZHIJIEBAHANSHUCHENGYUANDESHIXIANDAIMAYEXIEJINLEIDINGYILIMIAN。ZAIC++DELEIZHONG,RUGUOHANSHUCHENGYUANZAILEIDEDINGYITIZHONGBEIDINGYI,NEIMEBIANYIQIHUISHIZHEIGEHANSHUWEI NEILIANDE。YINCI,BAHANSHUCHENGYUANDEDINGYIXIEJINLEIDINGYITI,YIQIFANGJINTOUWENJIANZHONG,SHIHEFADE。ZHUYIYIXIA,RUGUOBAHANSHUCHENGYUANDEDINGYIXIEZAILEIDINGYIDETOUWENJIANZHONG,ERMEIYOUXIEJINLEIDINGYIZHONG, ZHEISHIBUHEFADE,YINWEIZHEIGEHANSHUCHENGYUANCISHIJIUBUSHINEILIANDELE。YIDANTOUWENJIANBEILIANGGEHUOLIANGGEYISHANGDE.cppWENJIANBAOHAN,ZHEIGEHANSHUCHENGYUANJIUBEIZHONGDINGYILE。

      YISHANGJIUSHIJINTIANJIDAJIAFENXIANGDEGUANYUC++ZHONGDETOUWENJIANHEYUANWENJIANDEXIANGGUANNEIRONGJIESHAOLE,XIANGXINKANLESHANGMIANZHEIXIENEIRONGDAJIADUIYUC++YOULEJIELEGENGDUOBA?RUGUODAJIAHAIXIANGLEJIEGENGDUOGUANYUC++DENEIRONGHUANYINGCHAKANBENZHANQITAFAWEN,XIAOBIANZHEILIJIUBUYIYIJIDAJIAJINXINGJIESHAOLE。

延伸阅读:

About IT165 - 广告服务 - 隐私声明 - 版权申明 - 免责条款 - 网站地图 - 网友投稿 - 联系方式
本站内容来自于互联网,仅供用于网络技术学习,学习中请遵循相关法律法规