如何将C++程序转为Pascal语法<br>原文出处: by Paul Fulford of Komodo Software<br>翻译:http://delphi.ktop.com.tw<br><br>将C++ 转为 Pascal/Delphi<br>==============================<br>目录<br>概论<br>数据型态<br>关键词<br>叙述结尾<br>变量宣告<br>字符串<br>数组<br>数值的指定与比较<br>常数宣告<br>函数与程序<br>with ... do叙述<br>批注<br>流程控制<br>对象导向结构<br>Containers<br>例外处理<br>资料流(Streaming)<br>项目档的设计<br>如何转换<br>结论<br>=================================<br>概论:<br>这篇文章的目的是让您了解C++与Object Pascal的不同<br>也让您能够有能力将C++转为Object Pascal(以下称为OP)<br>=================================<br>数据型态<br>这一章可学到如何将 C++ 的数据型态 转成 OP 的数据型态.<br>变量宣告时可参考下列对照表<br>C++ OP 大小 (bytes) 值范围<br>==================================================================<br>char ---- 1 -128 to 127<br>---- char 1 1 ASCII character<br>int integer 2 -32,768 to 32,767<br>short ---- 2 -32,768 to 32,767<br>---- shortint 1 -128 to 127<br>long longint 4 -2,147,483,647 to 2,147,483,647<br>unsigned char byte 1 0 to 255<br>unsigned int word 2 0 to 65,535<br>unsigned short word 2 0 to 65,535<br>unsigned long ---- 4 0 to 4,294,967,295<br><br>float single 4 3.4E-38 TO 3.4E+38<br>double double 8 1.7E-308 TO 1.7E+308<br>long double extended 10 3.4E-4932 TO 3.4E+4932<br>---- comp 8 1.7E-308 TO 1.7E+308<br>---- real (for backwards compatibility only -- use double)<br><br>void pointer 8 n/a -- an untyped pointer<br>---- boolean 1 True or False<br>(C++ may soon have a boolean type)<br>String ---- a C++ standard object<br>---- string an array of up to 255 ASCII characters<br>---- PChar pointer to a null-terminated string<br>=================================================================<br><br>=================================<br>关键词<br>C++ 有 59 个关键词, OP 有 60 个关键词. This does not include the many vendor<br>C++ 大小写有分 OP 大小写不分<br><br>C++的关键词<br>asm auto break case catch cdecl char class const const_cast continue<br>default delete do double dynamic_cast else enum extern far float for<br>friend goto huge if inline interrupt int near new operator pascal private<br>protected public register reinterpret_cast return short signed sizeof<br>static static_cast struct switch template this throw try typedef typeid<br>union unsigned virtual void volatile wchar_t while<br>OP的关键词<br>and as asm array begin case class const constructor destructor div do <br>downto else end except exports file finally for function goto if implementation <br>in inherited inline initialization interface is label library mod nil not <br>object of or packed procedure program property raise record repeat set shl<br>shr string then to try type unit until uses var while with xor<br>=================================<br>叙述结尾<br>C++叙述结尾<br>大部份的叙述都用 ; 号结尾<br>有一些例外如:<br>#include <br>#define MAXNAMELENGTH 35<br><br>OP叙述结尾<br>所有的叙述都用 ; 号结尾<br>=================================<br>变量宣告<br>C++变量宣告<br>变量名称只有前32个字有效<br>变量名称宣告可在程序的任何地方宣告(当然,宣告后才可用)<br>// ... 如在程序中宣告<br>{<br>char i;<br>for (i=0;i<10;i++)<br>{<br>char sName[10]; // 在区块中也可宣告变量<br>int iCount, iLoop, iValToReach;<br>double dMaxLoan, dTotal;<br>float fMaxRate = 123.875;<br>}<br>}<br>OP变量宣告<br>变量名称只有前63个字有效<br>变量名称要宣告在var之后,且要在function或procedure开始时宣告<br>不可在区块内宣告变量<br>如:<br>function PayBack_d(var dAmount: double): double;<br>var<br>iCount, iLoop, iValToReach: integer;<br>dMaxLoan, dTotal, dMaxRate: double;<br>begin<br>dMaxRate := 123.875;<br>{...}<br><br>=================================<br>字符串<br>C++字符串<br>在C++现在也有了字符串对象,但并不和以"/0"结束的char相容.<br>大部份的字符串就是char数组,可以无限长度.<br>下面是一些char数组宣告的例子:<br>char sName[26]; // 25 个chars长<br>char psDemo[] = "Hello, there!"; <br>char * psDemo = new char[26];<br>对字符串变量最常做的事就是strcpy与strcat<br>您要确定strcat或strcpy后的长度够不够存放.<br>以下是strcpy/strcat的例子.<br>class Ticker<br>{<br>...<br>public:<br>char sBuf[10],<br>sLatestTrade[TRADELENGTHBUF],<br>saTradeRecords[50] [TRADELENGTHBUF];<br>...<br>void OptnFormat2_v(unsigned long & ulQuantity,<br>CompanyC * poC,<br>int & iSeries);<br>...<br>};<br>...<br>void TickerC::OptnFormat2_v(unsigned long & ulQuantity,<br>CompanyC * poC,<br>int & iSeries)<br>{<br>ultoa(ulQuantity, sBuf, 10);<br>strcpy(sLatestTrade, sBuf);<br>AddMosToString_v(sLatestTrade,<br>poC->oSOS.oSeries[iSeries].oExpDate.enMonth);<br>itoa(poC->oSOS.oSeries[iSeries].oExpDate.iDay, sBuf, 10);<br>strcat(sLatestTrade, sBuf);<br>strcat(sLatestTrade, poC->oS.sTicker);<br>double dStrike = poC->oSOS.oSeries[iSeries].dStrike;<br>gcvt(dStrike, 3, sBuf);<br>strcat(sLatestTrade, sBuf);<br>if(poC->oSOS.oSeries[iSeries].enCallPut == Call)<br>strcat(sLatestTrade, "Calls"
;<br>else strcat(sLatestTrade, "Puts"
;<br>}<br><br>OP字符串<br>Delphi 1.0字符串最多255bytes,Delphi 2.0以后无此限.<br>在OP内的String所占的记忆空间会比您宣告的大小大.<br>因为字符串为数组,在数组[0]放长度.<br>例:<br>var<br>sMyName: string[25]; {最大25字符}<br>sYourName: string;<br>begin<br>sMyName := 'Paul Fulford'; {单引号表字符串}<br>在OP中,您可用:=和+处理字符串运算,例:<br>TickerC = class<br>...<br>public<br>sLatestTrade: string[TRADELENGTHBUF];<br>saTradeRecords: TStringList;<br>...<br>procedure TickerC.OptnFormat2(var lQuantity: longint;<br>poC: CompanyC;<br>var iSeries: integer);<br>...<br>end;<br>...<br>procedure TickerC.OptnFormat2(var lQuantity: longint;<br>poC: CompanyC;<br>var iSeries: integer);<br>begin<br>sLatestTrade := IntToStr(lQuantity);<br>AddMosToString(sLatestTrade,<br>poC.oSOS.oSeries[iSeries].oExpDate.enMonth);<br>sLatestTrade := sLatestTrade +<br>IntToStr(poC.oSOS.oSeries[iSeries].oExpDate.iDay) +<br>poC.oS.sTicker +<br>FloatToStr(poC.oSOS.oSeries[iSeries].dStrike);<br>if poC.oSOS.oSeries[iSeries].enCallPut = Call then<br>sLatestTrade := sLatestTrade + 'Calls'<br>else sLatestTrade := sLatestTrade + 'Puts';<br>end; {OptnFormat2}<br><br>您会发现OP处理字符串容易得多.<br>C++中字符串以"/0"结尾,OP中数组[0]放字符串长度.<br>=================================<br>数组<br>数组是数据的一序列排列.<br>C++与OP的数组宣告很不同.<br>但取用方式很像.<br><br>C++数组<br>数组从0开始,第一个元素为 [0], 第二个为[1]...类推,初学者要小心<br>// 宣告 数组...<br>DateC aoCANHolidays[SIZE_HOLIDAYARRAY];<br>double dAverageLast31Days[31];<br>// 取用数组<br>for(int i = 30, j = 29; i > 0; i--,j--)<br>dAverageLast31Days
= dAverageLast31Days[j];<br><br>OP数组<br>数组通常从[1]开始,但也不全然.<br>在Delphi中您也可以发现某些对象也是从[0]开始的.<br>像TList就是从TList[0]开始,我们要小心看对象的说明文件.<br>例子:<br>var<br>aoCANHolidays: array[1..SIZE_HOLIDAYARRAY] of DateC;<br>dAverageLast31Days: array[1..31] of double;<br>i,j: integer;<br>begin<br>j := 30;<br>for i := 31 downto 2 do<br>begin<br>dAverageLast31Days = dAverageLast31Days[j];<br>Dec(j); { or j := j-1; }<br>end;<br><br><br>两个语言都可用多维数组,见下例:<br><br>C++<br>double dMatrix[50] [20];<br><br>OP<br>var<br>dMatrix: array[1..50, 1..20] of double;<br><br><br>=================================<br>数值的指定与比较<br>C++数值的指定与比较<br>比较相等时用 == 号<br>给定值时用 = 号<br>如:<br>if (dMaxRate == 15.75)<br>{ ...<br>dMaxRate = 12.5;<br>...<br>}<br><br>OP数值的指定与比较<br>比较相等时用 = 号<br>给定值时用 := 号<br>如:<br>if dMaxRate = 15.75 then<br>begin<br>...<br>dMaxRate := 12.5;<br>...<br>end;<br>有一个例外就是OP在Const的值的给定是用=号,如:<br>const max=100;<br>=================================<br>常数宣告<br>常数是无法改变值的,所以一定要在宣告时给值.<br>C++常数宣告<br>const int iMax = 2000;<br>const double dMaxValue = 1234.75;<br>也可用宏定义常数<br>#define nMAXAMOUNT 1000<br><br>OP常数宣告<br>function PayBack_d(var dAmount: double): double;<br>const<br>iMAX = 2000; {notice value assigned with single equal sign this time}<br>dMAXVALUE = 1234.75;<br>var<br>iCount, iLoop, iValToReach: integer;<br>dMaxLoan, dTotal, dMaxRate: double;<br>begin<br>dMaxRate := dMAXVALUE;<br>{...}<br>=================================<br>函数与程序<br>在C++中所有的Function一定会传回值.<br>在OP中function要传回值,procedure不用<br>在C++中所有的function一定要()号,就算无参数<br>在OP中function无参数不用()号<br>C++函数与程序<br>例:<br>double IntSinceLastAddDate_d(double &dAvailCash); // prototype<br>void SetNewIntRate(); // no parameters or return value<br>...<br>double LoanC::IntSinceLastAddDate_d(double &dAvailCash)<br>{<br>double dSomething;<br>...<br>return dSomething;<br>}<br><br>void LoanC::SetNewIntRate()<br>{ ... }<br><br><br>OP函数与程序<br>例:<br>function IntSinceLastAddDate_d(var dAvailCash: double): double;<br>procedure SetNewIntRate; {无参数也无传回值}<br>...<br>function LoanC.IntSinceLastAddDate_d(var dAvailCash: double): double;<br>var<br>dSomething: double;<br>begin<br>...<br>result := dSomething; <br>{the global variable "result" is assigned the return value!}<br>end;<br><br>procedure LoanC.SetNewIntRate;<br>begin<br>...<br>end;<br><br>两个语言可以在参数传递时采用 pass by valye 或 pass by reference:<br><br>C++ pass by value ... double IntSinceLastAddDate_d(double dAvailCash);<br>OP pass by value ... function IntSinceLastAddDate_d(dAvailCash: double): double;<br>C++ pass by reference ... double IntSinceLastAddDate_d(double &dAvailCash);<br>OP pass by reference ... function IntSinceLastAddDate_d(var dAvailCash: double): double;<br>C++ pass constant ... double IntSinceLastAddDate_d(const double dAvailCash);<br>OP pass constant ... function IntSinceLastAddDate_d(const dAvailCash: double): double;<br><br>=================================<br>with ... do叙述<br>C++无 with .. DO叙述<br>在C++中当您要取用资料时:<br>poC.oStock.aoTradesLast130Days[0].lVol = 0;<br>poC.oStock.aoTradesLast130Days[0].dHigh = 0;<br>poC.oStock.aoTradesLast130Days[0].dLow = 0;<br>poC.oStock.aoTradesLast130Days[0].dClose = 0;<br>但在OP中可以简化成:<br>with poC.oStock.aoTradesLast130Days[0] do<br>begin<br>lVol := 0;<br>dHigh := 0;<br>dLow := 0;<br>dClose := 0;<br>end;<br><br>=================================<br>批注<br>C++<br>有两种<br>// 双斜线后为批注<br>/* 批注 */<br><br>OP<br>有三种<br>// 双斜线后为批注<br>{ 批注 }<br>(* 批注 *)<br>=================================<br>流程控制<br>有五种流程控制指令,C++与OP都有,用法满像的.<br>~~~~~~~~~~~~~~~~~~~~~~~~~<br>1) if ... else 指令<br><br>C++<br><br>if(<逻辑表达式> // 一定要有()号<br>{ ...<br>}<br>else if(<逻辑表达式><br>{...<br>}<br>else<br>{...<br>}<br><br>OP<br><br>if <逻辑表达式> then // 不一定要有()号,因有then<br>begin<br>...<br>end<br>else if <逻辑表达式> then<br>begin<br>....<br>end<br>else<br>begin<br>...<br>end; {最后一个end才要加;分号}<br><br>~~~~~~~~~~~~~~~~~~~~~~~~~<br>2) switch/case ... 指令<br>C++<br><br>switch()<br>{<br>case iX: ... break;<br>case iY: ... break;<br>default: ...<br>}<br><br>OP<br><br>case of<br>{no "begin" here}<br>iX: <br>begin<br>...<br>end; {每个end都要;分号}<br>iY:<br>begin<br>...<br>end;<br>else {此处不用;号}<br>begin<br>...<br>end;<br>end; {这个end要;分号}<br><br><br>~~~~~~~~~~~~~~~~~~~~~~~~~<br>3) for ... loop 指令<br>C++<br><br>for(iCount = 0; iCount <= 10; iCount++)<br>{ <br>// iCount++, 每次循环值加一<br>...<br>break; // 中断循环<br>continue; // 跳到下一个循环<br>...<br>}<br><br><br>OP<br><br>for iCount := 1 to 10 do<br>begin<br>... {iCount每次自动加 1}<br>break; { 中断循环 }<br>continue; { 跳至下一个循环 }<br>...<br>end;<br><br>~~~~~~~~~~~~~~~~~~~~~~~~~<br>4) while ... loop 指令<br>C++<br><br>while(<逻辑表达式><br>{<br>...<br>break; // 中断循环<br>continue; // 跳到下一个循环<br>...<br>}<br><br><br>OP<br><br>while <逻辑表达式> do<br>begin<br>...<br>break; { 中断循环 }<br>continue; { 跳至下一个循环 }<br>...<br>end;<br>~~~~~~~~~~~~~~~~~~~~~~~~~<br>5) do/repeat ... 指令<br>C++<br><br>do<br>{<br>// 逻辑表达式 False循环终止<br>...<br>break; // 中断循环<br>continue; // 跳到下一个循环<br>...<br>}while(<逻辑表达式><br><br><br>OP<br><br>repeat<br>// 逻辑表达式 True循环终止<br>...<br>break; { 中断循环 }<br>continue; { 跳至下一个循环 }<br>...<br>until <逻辑表达式>;<br>================================= <br>对象导向结构<br>C++与OP都可称为是对象导向式的语言.<br>C++可以用多重继承(multiple inheritance),OP只能单一继承(single inheritance)<br>让我们来看看建立对象的基本语法:<br><br>C++<br>Classes必须定义在header檔中...<br>class LoanC // 未有继承时<br>{<br>private: // 内定为private<br>...<br>protected: // 要有冒号<br>...<br>public:<br>...<br>}; //分号结尾<br><br>在C++中单一继承的语法如下:<br>class B: A<br>{...};<br><br>在C++中多重继承的语法如下:<br>class D: A, B, C<br>{...};<br><br>classes继承对象时可标明public, protected, 或 private.<br>内定是为 private<br>class D: public A, public B, private C<br>{...};<br><br>OP<br>Classes是在unit/file中的 "type" 结构中宣告...<br>type<br>LoanC = class(TObject) <br>{这表是从TObject继承下来. }<br>{此处不用 "begin" 指令}<br>private<br>...<br>protected {此处不用冒号}<br>...<br>public<br>...<br>published<br>...<br>end;<br>关键词 private, protected, public, 及 published (只有OP有) 指明了<br>每一个数据元素的数据范围宽广.<br>private:只能给在Class内部使用<br>protected:只能给这个Class或演生的Class使用<br>public:可以在程序所有的地方使用<br>Publishedelphi专用,用来建立接口<br>每一个Class需要一个建立者(constructor)<br>在C++理,建立者与class同名.<br>建立者可加参数:<br>ie:<br>LoanC(); // 无参数<br>LoanC(double &dCurrentBal); // 一个参数<br>LoanC(double &dBalOne, double &dBalTwo); // 两个参数<br><br>在OP理,建立者与class不同名.<br>ie:<br>constructor MyLoanOne; {no parameters}<br>constructor MyLoanTwo(var dCurrentBal: double);<br>constructor MyLoanThree(var dBalOne, dBalTwo: double);<br>C++与OP都提供解构者(destructors),也可称为释放内存(free memory)<br>在C++理, 解构者与建构者一样,与class同名.<br>如:<br>~LoanC(); // C++ destructor<br><br>在OP理, 解构者与class不同名.<br>如:<br>destructor LoanC.Destroy;<br>begin<br>oLoanDate.Free;<br>...<br>inherited Destroy; {"inherited" is a keyword}<br>end;<br>建立一个新对象,宣告一个变量:<br>double dAmount = 1515.75;<br>LoanC oMyLoan(dAmount);<br>如此做会配置一块内存,<br>如果用只标方式可以如下宣告:<br>double dAmount = 1515.75;<br>LoanC * poMyLoan = new LoanC(dAmount);<br>在OP理则不同,每一个都是指标.<br>var<br>dAmount: double;<br>oMyLoan: LoanC;<br>begin<br>{oMyLoan does not yet exist!}<br>dAmount := 1515.75;<br>oMyLoan := LoanC.MyLoanTwo(dAmount); {now it does}<br>在OP理也可也 Override.<br>type<br>LoanC = class<br>...<br>constructor Create; {overrides TObject's Create}<br>...<br>end;<br>... and call the inherited Create constructor in the LoanC definition...<br>constructor LoanC.Create;<br>begin<br>inherited Create; {calls TObject's Create}<br>...<br>end;<br><br>C++与OP理引用内部元素采用如下语法:<br>oMyLoan.dPrincipal;<br>在C++中,使用指针引用内部元素采用如下语法:<br>poMyLoan->dPrincipal;<br>在C++中有三个运操作数:<br>1. & 取地址<br>2. * 取指标<br>3. -> 印用元素<br>在OP中都用.(逗点号)<br>=================================<br>Containers<br>C++:Containers<br>typedef TISetAsVector tdCompanySet;<br>typedef TISetAsVectorIterator tdCSetIter;<br>...<br>int OwlMain(int, char*[])<br>{...<br>tdCompanySet oCompColl;<br>...<br>}<br>...<br>void MainForm::AddNewCompany()<br>{<br>CompanyC * poC = new CompanyC;<br>oCompColl.Add(new CompanyC(poC));<br>...<br>// now iterate<br>tdCSetIter oCIter(oCompColl);<br>while(oCIter)<br>{<br>poC = oCIter++;<br>// now use poC<br>...<br>}<br>}<br>OP:Containers<br>TMainForm = class(TForm)<br>...<br>public<br>oCompColl: TList;<br>...<br>end;<br>...<br>procedure TMainForm.AddNewCompany;<br>var<br>poC: CompanyC;<br>iCount: integer;<br>begin<br>poC := CompanyC.Create;<br>...<br>oCompColl.Add(poC);<br>...<br>{now iterate}<br>for iCount := 0 to oCompColl.Count - 1 do<br>begin<br>poC := oCompColl.Items[iCount];<br>{now use poC}<br>...<br>end;<br><br>=================================<br>例外处理<br>C++:例外处理<br>try<br>{<br>...<br>}<br>catch()<br>{<br>...<br>}<br>catch(...)<br>{<br>...<br>}<br><br><br>OP:例外处理<br>try<br>{不用 begin ... end; 指令}<br>...<br>finally<br>{例外处理}<br>...<br>end;<br><br>取得Run Time 错误讯息时:<br>try<br>...<br>except<br>on do ... ;<br>end;<br><br>=================================<br>资料流(Streaming)<br><br>C++:资料流<br>class CompanyC<br>{<br>...<br>friend ofstream & operator <<(ofstream &oS, CompanyC * poC);<br>...<br>};<br>...<br>friend ofstream & operator <<(ofstream &oS, CompanyC * poC)<br>{<br>oS << poC->dVersion<br><< poC->dLastDivPerShare<br><< poC->enIndustry<br>...<br><< poC->sName;<br>return oS;<br>}<br><br>friend ofstream & operator <<(ofstream &oS, CompanyC * poC)<br>{<br>oS.write( (char*) & (*poC), sizeof(*poC));<br>return oS;<br>}<br>// 打开 a stream<br>ofstream ofS("gamedata.gam"<br>if(!ofS) <br>return;<br>...<br>// 存档<br>tdCSetIter oCIter(oCompColl); // see container section<br>while(oCIter)<br>{<br>poC = oCIter;<br>ofS << poC;<br>}<br>ofS.close();<br><br><br>OP:资料流<br>type<br>CompanyC = class<br>public<br>procedure Read(var f:file);<br>procedure Write(var f:file);<br>...<br>end;<br>...<br>procedure CompanyC.Write(var f:file);<br>begin<br>BlockWrite(f, dVersion, sizeof(dVersion));<br>BlockWrite(f, dLastDivPerShare, sizeof(dLastDivPerShare));<br>BlockWrite(f, enIndustry, sizeof(enIndustry));<br>...<br>BlockWrite(f, sName, sizeof(sName));<br>end;<br><br>开档:<br>procedure TMainForm.FileSaveItemClick(Sender: TObject);<br>var<br>oGameFile: file;<br>iCount: integer;<br>poC: CompanyC;<br>sNameFile: string[13];<br>begin<br>...<br>sNameFile := 'gamedata.gam';<br>AssignFile(oGameFile, sFileName);<br>Rewrite(oGameFile, 1); {the 1 means 1 byte at a time}<br>...<br>for iCount := 0 to oCompColl.Count - 1 do<br>begin<br>poC := oCompColl.Items[iCount];<br>poC.Write(oGameFile);<br>end;<br>CloseFile(oGameFile);<br>end;<br><br>=================================<br>项目档的设计<br>在 C++中,常数定义放在.h文件中,程序放在.cpp中(会用#include .h檔)<br>在 Delphi中,常数定义与程序都在一个文件.pas中<br>不同的.pas可用uses指令引用别的.pas宣告个变量<br>=================================<br>如何转换<br>如果要转有画面的C++程序要比转无画面的C++程序困难的多.<br>如果要转有画面的C++程序,要先在Dlephi开一Form,再将c++的程序代码转入.<br>要将程序copy 至delphi中再来改.<br>1) 先整体性的转换 ,将 C++ 的{...} 改为 begin...end;<br>double CompanyC::NewAnnualReport_v(Economy & oE)<br>{ ... // delimiter starts on a new line<br>}<br><br>...versus this...<br>double CompanyC::NewAnnualReport_v(Economy & oE){ // delimiter at end of line<br>... <br>}<br><br>2) a) 将 C++ 的 || 转为 "or"<br>b) 将 C++ 的 && 转为 "and"<br>c) (1)将 C++ 的 == 转为 =<br>(2)将 C++ 的 = 转为 :=<br>d) 将 C++ 的 /* */ 转为 { }<br>e) C++的 // 不用转<br>f) 将 双引号转为单引号 " -> '<br><br>3) C++的每个if要加 then<br>如:<br>C++<br>if(oE.enDirection == Up &&<br>oE.uNumMosUpYr >= oE.uNumMosDownYr)<br>{<br>...<br>}<br><br>OP<br>if (oE.enDirection = Up) and<br>(oE.iNumMosUpYr >= oE.iNumMosDownYr) then<br>begin<br>...<br>end;<br><br>4) 将控制指令修改<br><br>5) C++的 overloaded 运算可 re-written,那就看您在OP中要如何处理.<br>6) 将 C++ 的 :: 转为 .<br>procedure TForm1.Memo1Change(Sender: TObject); {要加上分号}<br>begin<br>...<br>end;<br>7) 将 C++ 的 ++ 和 decrement -- 改为inc(x) 与dec(<br>8) 将C++在区块 中宣告的变量全部移到var区中.<br>9) 将C++的函数名称前加上 "function" 或 "procedure"<br>10) 将 C++ 的 -> 转为 . (句点)<br>DateC oBirthDate;<br>var<br>oBirthDate: DateC;<br>begin<br>oBirthDate := DateC.Create;<br>11) 将 C++ 的strcpy(...) 与 strcat(...) 转为 := 与 +<br><br>12) 那多重继承呢?( multiple inheritance).<br>用Class B继承Class A,再用class C继承 B的方式 .<br>=================================<br>结论<br>C++ 是简短的语言, 而 OP 比较像英文.<br>然而C++较紧密,但不易阅读.<br><br>============完结=============