| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> delphi >> Delphi he C++ de yu fa qu bie

Delphi he C++ de yu fa qu bie

2006-12-05 19:16:37 编辑來源:互联网 评论
 
 
 
本文为【Delphi和C++的语法区别】的拼音翻译版
  mu lu
   Delphi yong yuan mei ban fa zai zhan shang chuang jian yi ge dui xiang
   Delphi de gou zao han shu geng xiang shi ge lei fang fa ( jing tai cheng yuan han shu )
   Delphi de xi gou han shu zhong ke yi tiao yong chun xu fang fa
   Delphi zai gou zao dui xiang shi zi dong jiang cheng yuan bian liang qing ling
   Delphi gou zao han shu zhong pao chu yi chang hui zi dong xian tiao yong xi gou han shu
   Delphi jian hua le COM jie kou de AddRef、Release he QueryInterface
  yi 、Delphi yong yuan mei ban fa zai zhan shang chuang jian yi ge dui xiang
  xia mian shi yi duan chang jian de de Delphi dai ma , zai guo cheng de kai tou sheng ming ben guo cheng suo xu yao de quan bu ju bu bian liang :
  procedure Foo;
  var
  obj: TObject; // zhe ju rong yi bei C++ cheng xu yuan wu hui 。
  begin
  ...
  end;
  C++ cheng xu yuan hui yi wei obj zhe ge bian liang jiu shi TObject dui xiang shi li ben shen , hui yi wei zhe yi ju shi zai zhan shang sheng ming bing gou zao le TObject lei de yi ge dui xiang shi li , ta men hui yu xia mian de C++ dai ma hun xiao :
  void Foo() { CObject obj; // zhe yi ju de que zai zhan shang gou zao le CObject lei de
   ... // yi ge dui xiang shi li , bing qie jiang zai li kai Foo han shu shi zi dong xi gou ta
  }
  lao ji yi dian , zai Delphi li , yong yuan bu ke neng zai zhan shang gou zao yi ge dui xiang , ye yong yuan bu ke neng dui yi ge dui xiang jin xing zhi chuan di , cheng xu yuan neng kan dao de shi “ zhi xiang dui xiang shi li de zhi zhen ”, jian dan di shuo “ yi qie jie zhi zhen ”, shang li zhong obj qi shi jiu shi yi ge “TObject lei xing de zhi zhen ”, dang ta zai zhan shang bei sheng ming de shi hou , ta de zhi bu ke zhi ( yu C++ yi yang ), ye mei you ren he dui xiang bei gou zao chu lai 。 shang shu dai ma fan yi cheng C++, ji ben shang jiu shi :
  void Foo() {
   CObject * obj; // sheng ming yi ge CObject lei xing de zhi zhen
   // dan mei you ren he dui xiang bei gou zao huo yu zhi guan lian
   ...
  }
  zuo wei yi ge zuo zheng , zai Delphi li ,sizeof(TObject), sizeof(Self), sizeof(obj) jie guo dou shi 4, ji yi ge 32 wei zhi zhen de da xiao 。
  er 、Delphi de gou zao han shu geng xiang shi ge lei fang fa ( jing tai cheng yuan han shu )
  you yu Delphi bu yuan xu zai zhan shang gou zao dui xiang , na me dui xiang shi li jiu zhi neng chuang jian zai dui shang ,Delphi mei you new guan jian zi ( dao you yi ge ming wei New de procedure), er shi yong yi zhong you bie yu C++ de yu fa lai ( zai dui shang ) gou zao dui xiang :
  procedure Foo;
  var
  obj: TObject; //obj ben zhi shang zhi shi yi ge TObject lei xing de zhi zhen
  begin
  obj := TObject.Create; // zai dui shang gou zao yi ge TObject dui xiang shi li bing jiang qi di zhi fu zhi gei obj
  obj.Free; // ling obj zhi xiang de dui xiang xi gou
  end;
  yu C++ yi yang , zai dui shang gou zao de han shu bu hui zai li kai zuo yong yu de shi hou bei zi dong xi gou , suo yi zai li kai Foo zhe ge guo cheng zhi xie , yao tiao yong TObject de Free fang fa lai xi gou ta 。Free fang fa hui tiao yong Destroy xi gou han shu , zhi bu guo zai tiao yong Destroy zhi qian hui pan duan Self shi fou wei kong , ru guo wei kong jiu zhi jie fan hui 。Delphi li de Self, jiu shi C++ li de this。
  Delphi shi dan gen ji cheng , suo you lei dou cong TObject pai sheng er lai , er suo you lei de gou zao han shu yi ding ming wei Create, er xi gou han shu yi ding ming wei Destroy, dang ran , xi gou han shu ken ding shi xu han shu 。
  cong sheng ming de xing shi shang kan ,Create fang fa xiang shi yi ge cheng yuan han shu , dan cong shi yong shang kan , ta geng xiang yi ge lei fang fa (C++ li jiao jing tai cheng yuan han shu ), yin wei tiao yong ta de shi hou , xian ding ming bu shi dui xiang , er shi lei ming (Txxxxx.Create)。
  san 、Delphi de xi gou han shu zhong ke yi tiao yong chun xu fang fa
  you yu zai Delphi de xi gou han shu Destroy li , ke yi tiao yong ren he chun xu han shu ( zai C++ li zhe yi dian shi bu ke xiang xiang de ), suo yi ke yi ren wei zhe ge shi hou , xu fang fa biao you yi ding wei bei po huai , na me , ru guo ji lei jiu ke yi jue ding xi gou shi yi ding yao tiao yong de han shu , na pa zhe ge han shu shi ge xu han shu , shen zhi chun xu han shu 。
  si 、Delphi zai gou zao de shi hou zi dong jiang cheng yuan bian liang qing ling
  ren he yi ge Delphi zhong de lei , dang ta bei gou zao hou , ta de suo you cheng yuan bian liang bei qing ling , bu er xing chu shi wei False, zi fu chuan chu shi wei kong , zheng xing he fu dian xing chu shi hua wei 0…… er C++ mei you zhe yang de bao zheng
  wu 、Delphi gou zao han shu zhong pao chu yi chang hui zi dong xian tiao yong xi gou han shu
  Delphi li , ru guo gou zao han shu zhong pao chu le yi chang , ze hui zi dong xian zhi xing xi gou han shu , ran hou zai ba yi chang xiang wai pao chu ; er zai C++ li , gou zao han shu zhong ruo you yi chang pao chu , ze xi gou han shu shi bu hui bei tiao yong de 。
  liu 、Delphi jian hua le COM jie kou zhong de AddRef、Release he QueryInterface
  C++ li yi ban yong mo ban dui COM jie kou jin xing feng zhuang , er zai Delphi li ,AddRef、Release yi ji QueryInterface dou bei bian yi qi yin cang diao le , dang ba yi ge IUnknown lei xing de bian liang ( ben zhi shang ye shi yi ge zhi zhen ) fu zhi gei ling yi ge bian liang shi , bian yi qi zai bei hou zi dong AddRef, dang yi ge IUnknown bian liang li kai zuo yong yu de shi hou ( zai ye mei you ren shi yong ta ),Release bei zi dong tiao yong , er QueryInterface bei chou xiang wei AS yun suan fu :
  procedure Foo(const AParam: IUnknown);
  var
  bar: IUnknown;
  other: IStream;
  begin
  bar := AParam; //AParam zhi xiang de shi li you yu fu zhi cao zuo bei AddRef yi ci
  other := bar as IStream; // tiao yong le yi ci QueryInterface, yin yong ji shu zai ci jia yi
  end; // fan hui shi ,other he bar dou li kai zuo yong yu , fen bie bei tiao yong Release ge yi ci
  C++ zhong yong mo ban ( bi ru _com_ptr) ye ke yi shi yin yong ji shu zi dong hua , bu guo QueryInterface jiu mei na me fang bian le 。【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
mu lu [url=http://dev.csdn.net/#stack_instance]Delphi yong yuan mei ban fa zai zhan shang chuang jian yi ge dui xiang [/url] [url=http://dev.csdn.net/#class_method]Delphi de gou zao han shu geng xiang shi ge lei fang fa ( jing tai cheng yuan han shu )[/url] [url=http://dev.csdn.net/#call_pure_virtual]Delphi de xi gou han shu zhong ke yi tiao yong chun xu fang fa [/url] [url=http://dev.csdn.net/#auto_clear]Delphi zai gou zao dui xiang shi zi dong jiang cheng yuan bian liang qing ling [/url] [url=http://dev.csdn.net/#constructor_exception]Delphi gou zao han shu zhong pao chu yi chang hui zi dong xian tiao yong xi gou han shu [/url] [url=http://dev.csdn.net/#COM]Delphi jian hua le COM jie kou de AddRef、Release he QueryInterface[/url] yi 、Delphi yong yuan mei ban fa zai zhan shang chuang jian yi ge dui xiang xia mian shi yi duan chang jian de de Delphi dai ma , zai guo cheng de kai tou sheng ming ben guo cheng suo xu yao de quan bu ju bu bian liang : procedure Foo; var obj: TObject; // zhe ju rong yi bei C++ cheng xu yuan wu hui 。 begin ... end; C++ cheng xu yuan hui yi wei obj zhe ge bian liang jiu shi TObject dui xiang shi li ben shen , hui yi wei zhe yi ju shi zai zhan shang sheng ming bing gou zao le TObject lei de yi ge dui xiang shi li , ta men hui yu xia mian de C++ dai ma hun xiao : void Foo() { CObject obj; // zhe yi ju de que zai zhan shang gou zao le CObject lei de ... // yi ge dui xiang shi li , bing qie jiang zai li kai Foo han shu shi zi dong xi gou ta } lao ji yi dian , zai Delphi li , yong yuan bu ke neng zai zhan shang gou zao yi ge dui xiang , ye yong yuan bu ke neng dui yi ge dui xiang jin xing zhi chuan di , cheng xu yuan neng kan dao de shi “ zhi xiang dui xiang shi li de zhi zhen ”, jian dan di shuo “ yi qie jie zhi zhen ”, shang li zhong obj qi shi jiu shi yi ge “TObject lei xing de zhi zhen ”, dang ta zai zhan shang bei sheng ming de shi hou , ta de zhi bu ke zhi ( yu C++ yi yang ), ye mei you ren he dui xiang bei gou zao chu lai 。 shang shu dai ma fan yi cheng C++, ji ben shang jiu shi : void Foo() { CObject * obj; // sheng ming yi ge CObject lei xing de zhi zhen // dan mei you ren he dui xiang bei gou zao huo yu zhi guan lian ... } zuo wei yi ge zuo zheng , zai Delphi li ,sizeof(TObject), sizeof(Self), sizeof(obj) jie guo dou shi 4, ji yi ge 32 wei zhi zhen de da xiao 。 er 、Delphi de gou zao han shu geng xiang shi ge lei fang fa ( jing tai cheng yuan han shu ) you yu Delphi bu yuan xu zai zhan shang gou zao dui xiang , na me dui xiang shi li jiu zhi neng chuang jian zai dui shang ,Delphi mei you new guan jian zi ( dao you yi ge ming wei New de procedure), er shi yong yi zhong you bie yu C++ de yu fa lai ( zai dui shang ) gou zao dui xiang : procedure Foo; var obj: TObject; //obj ben zhi shang zhi shi yi ge TObject lei xing de zhi zhen begin obj := TObject.Create; // zai dui shang gou zao yi ge TObject dui xiang shi li bing jiang qi di zhi fu zhi gei obj obj.Free; // ling obj zhi xiang de dui xiang xi gou end; yu C++ yi yang , zai dui shang gou zao de han shu bu hui zai li kai zuo yong yu de shi hou bei zi dong xi gou , suo yi zai li kai Foo zhe ge guo cheng zhi xie , yao tiao yong TObject de Free fang fa lai xi gou ta 。Free fang fa hui tiao yong Destroy xi gou han shu , zhi bu guo zai tiao yong Destroy zhi qian hui pan duan Self shi fou wei kong , ru guo wei kong jiu zhi jie fan hui 。Delphi li de Self, jiu shi C++ li de this。 Delphi shi dan gen ji cheng , suo you lei dou cong TObject pai sheng er lai , er suo you lei de gou zao han shu yi ding ming wei Create, er xi gou han shu yi ding ming wei Destroy, dang ran , xi gou han shu ken ding shi xu han shu 。 cong sheng ming de xing shi shang kan ,Create fang fa xiang shi yi ge cheng yuan han shu , dan cong shi yong shang kan , ta geng xiang yi ge lei fang fa (C++ li jiao jing tai cheng yuan han shu ), yin wei tiao yong ta de shi hou , xian ding ming bu shi dui xiang , er shi lei ming (Txxxxx.Create)。 san 、Delphi de xi gou han shu zhong ke yi tiao yong chun xu fang fa you yu zai Delphi de xi gou han shu Destroy li , ke yi tiao yong ren he chun xu han shu ( zai C++ li zhe yi dian shi bu ke xiang xiang de ), suo yi ke yi ren wei zhe ge shi hou , xu fang fa biao you yi ding wei bei po huai , na me , ru guo ji lei jiu ke yi jue ding xi gou shi yi ding yao tiao yong de han shu , na pa zhe ge han shu shi ge xu han shu , shen zhi chun xu han shu 。 si 、Delphi zai gou zao de shi hou zi dong jiang cheng yuan bian liang qing ling ren he yi ge Delphi zhong de lei , dang ta bei gou zao hou , ta de suo you cheng yuan bian liang bei qing ling , bu er xing chu shi wei False, zi fu chuan chu shi wei kong , zheng xing he fu dian xing chu shi hua wei 0…… er C++ mei you zhe yang de bao zheng wu 、Delphi gou zao han shu zhong pao chu yi chang hui zi dong xian tiao yong xi gou han shu Delphi li , ru guo gou zao han shu zhong pao chu le yi chang , ze hui zi dong xian zhi xing xi gou han shu , ran hou zai ba yi chang xiang wai pao chu ; er zai C++ li , gou zao han shu zhong ruo you yi chang pao chu , ze xi gou han shu shi bu hui bei tiao yong de 。 liu 、Delphi jian hua le COM jie kou zhong de AddRef、Release he QueryInterface C++ li yi ban yong mo ban dui COM jie kou jin xing feng zhuang , er zai Delphi li ,AddRef、Release yi ji QueryInterface dou bei bian yi qi yin cang diao le , dang ba yi ge IUnknown lei xing de bian liang ( ben zhi shang ye shi yi ge zhi zhen ) fu zhi gei ling yi ge bian liang shi , bian yi qi zai bei hou zi dong AddRef, dang yi ge IUnknown bian liang li kai zuo yong yu de shi hou ( zai ye mei you ren shi yong ta ),Release bei zi dong tiao yong , er QueryInterface bei chou xiang wei AS yun suan fu : procedure Foo(const AParam: IUnknown); var bar: IUnknown; other: IStream; begin bar := AParam; //AParam zhi xiang de shi li you yu fu zhi cao zuo bei AddRef yi ci other := bar as IStream; // tiao yong le yi ci QueryInterface, yin yong ji shu zai ci jia yi end; // fan hui shi ,other he bar dou li kai zuo yong yu , fen bie bei tiao yong Release ge yi ci C++ zhong yong mo ban ( bi ru _com_ptr) ye ke yi shi yin yong ji shu zi dong hua , bu guo QueryInterface jiu mei na me fang bian le 。
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
玉美人_珠联璧合
清纯美女米卡
清新靓丽的早晨
玲子的自信与性感
痞子的甘南日记
疑是银河落九天
雪域坝上四——纯美色
冬日恋歌——西城杨柳弄轻柔
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有