close

翻譯公司, C 語言中所有物件(變數、結構)的宣佈都要放在最前面,在 C++ 則沒有
                                                                               
  言歸正傳,所謂 object-based paradigm 和 object-oreinted paradigm ,
,不敷完全。事實上,C 和 C++ 的差距非常大翻譯
                                                                               
                                                                               
面提過的「利用者不需要為他沒有效到的功能付出效力的代價」,如許的抱負翻譯
                                                                               
                                                                               
                                                                               
  1. procedural-based paradigm

理念付諸實現。解決,只能好自為之翻譯但在 C++ 上,假如類別設計夠嚴謹,編譯/聯絡器每每可以
                                                                               
  舉例而言,在 C++ 中,你可以寫一個支援四則運算的超大整數 BigInt 的類別,
                                                                               
                                                                               
(包括以位元)操作記憶體的細密性翻譯
                                                                               
                                                                               
們行將會商的主題,C++ 就是靠著別的三項(C 說話其實不支援的)編程手藝,將此
 BigInt a翻譯社 b翻譯社 c;
一致的體式格局,模塑抽象的思惟世界翻譯這部份在觀念和手藝上都有相當程度的複雜性
                                                                               
而明白,例如你可以「輕易」寫出像 BigInt(超大整數)、VarLenInt(改觀長度的
不能說沒出缺點(沒出缺點就透露表現沒有前進空間了),但我照舊只能用獨一的「偉大」
這個限制。顯然,C++ 的體式格局比較公道,因為逼迫把宣告放在最前面,極可能
                                                                               
                                                                               
                                                                               
                                                                               
指向函式的指標這類禁斷手藝的語言,會在眾語言百家爭鳴下脫穎而出,也就不
它同時具有高階說話流程節制與資料處理的便當性,和低階說話直接
靈巧。  固然,連 C++ 的發現人都說,可以不消學 C,直接學 C++(敝人在之前一
                                                                               
的氣勢派頭完全分歧翻譯在多半人的心目中,C 是簡練、乖巧、短小精桿的,而 C++,固然
,就不多接洽了翻譯不外有一點可以提出來:只有少數的語言支援完全的多重擔當,
STL,程式設計師不消再每次本身寫 tree、list、stack、queue ...等等,也不需要
某些物件底子用不到,卻必需在函式每次履行的時候去設置裝備擺設記憶體。
封裝(encapsulation)的編程模式;爾後者涵蓋了擔當(inheritance)及動態繫
                                                                               
例如不小心把 BigInt 和浮點數混用;像這類的問題,在 C 上通常都沒有辦法完全
                                                                               
這二者等于幾年前一般所謂的「物件導向」編程模式(此刻之所以有所辨別,是因
,自由天真地操控記憶體。而在嚴謹的程序導向編程思惟的年月,像 C 這種支援
                                                                            讓它在利用上與內建型別毫無離別:
  其次,繼續和動態繫結,也就是 object-oriented 編程手藝,建築在封裝,
  2. object-based paradigm  
                                                                               
                                                                               
  sum += i^100;
                                                                               
  在注釋之前,先說一點,C 和 C++ 的不同的地方就在於,以上所列 C++ 的四
                                                                               
                                                                               
                                                                               
  c = -a/4 + b * 2;
                                                                               
                                                                               
                                                                               
斷發展進化的過程當中,直至今朝為止,已綜合歸納出,並且實現了四種分歧,而

object),來取代 C 的函式指標的手藝。                                                                               
                                                                               
問:「真的嗎?如果是真的,C++ 事實是怎麼做到的?」沒錯,而且這就是之前我
                                                                               
                                                                               
理、引入 exception 異常處置的機制、引入 namespace 定名空間的機制……等等,
                                                                               
 for (BigInt i=1; i<=100; ++i)
  C++ 用以具現泛型編程設計模式的體式格局,是引入樣版(template)及其他互相
                                                                               
                                                                               
  c %= d;
擴充性更高。
                                                                               
翻譯公司可以嚴酷地制定型別平安(type safe)的規格,儘早地讓錯誤的操作行為曝露,
和效力的精神,所透露的潛力被一致看好,泛型編程理念的很早就被引入了 C++,
                                                                               
                                                                               
                                                                               
                                                                               
一個,然後就可以簡單的計算像 1^100 + 2^100 + ... + 100^100 = ? 這類問題:
每一種編程技術的支援,都到達最完整的程度翻譯正因為它完整,才能儘可能貼近前
代 C 的巨集,引入 const、mutable、new、delete 等關鍵字,增強物件和記憶體管
                                                                               
                                                                               
                                                                               
                                                                               
在 C++ 中,供給了一種更嚴謹、具有型別平安(type safe)、更
向函式的指標。做),而可以甯神的利用兼具效能、移植性和擴充性的 STL 組件和演算法,大大提拔
                                                                               
加倍具有彈性和擴充性,同時不損失、甚至晉升效力)(唯一的瑕玷,呃……,大
、明確、彈性、擴充性、效率……等等的目標。例如以 const 和 inline 儘可能取
                                                                               
沒有供應多重繼承,而 Java 也只支援有限型式的多重繼續翻譯
                                                                               
  甚至,假如翻譯公司喜歡 BASIC 的次方(^)符號表式法,你可以在 C++ 中本身設計
引伸意義則是:「C++ 兼具了效力與彈性」翻譯舉個例子,天成翻譯社們都知道,在之前
                                                                               
                                                                               
 3. object-oriented paradigm
                                                                               
種編程思惟,C 只提拱了第一種,也就是天成翻譯社們常聽到的「程序(功能)導向」模
                                                                               
來形容它翻譯
                                                                               
一點只是想申明,C++ 不但支援四種首要的編程手藝,更主要的關頭在於:C++ 對
                                                                               
                                                                               
  C++ 承續了 C,當然也支援函式指標,但 C++ 程式的氣概,並不鼓動勉勵利用指
語法表達天然、明白,程式
整數)、Matrix(矩陣)、DateTime ……等等的種別。                                                                               
                                                                               
透過 C++ 種別(class)的封裝機制,你可讓程式語言表達地更天然、一致
編程。                                                                               
                                               像如許的語法表達,在沒有或對 object-based 編程技術支援不敷完整的說話
                                                                               
                                                                               
  固然,完整的多重繼續增添了語法的複雜度,利用上不見得是長處翻譯但提出這
                                                                               
                                                                               
                                                                               
                                                                               
是讓利用者可以自訂型別,而且在處理自訂型別時,和操作內建型別一樣天然、便
                                                                               
                                                                               
                                                                               
而 C++ 正是其中之一;其他如 Objective C, Object Pascal, Smalltalk 等,並
                                                                        ,仍是很有幫忙的翻譯
                                                                               
                                                                               
                                                                               
學習程式設計的思惟方法);但,要體味 C++ 的精髓,先領會 C 的特征和氣勢派頭
                                                                               
模式翻譯很幸運地,在 C++ 還不是很完整時,由於整個說話在各方面貫串了兼具彈性
                                                                               
                                                                               
不會比同樣功能的 C 程式碼最佳化後要差翻譯
                                                                               
                                                                               
或,常聽到有人說,C++ 是 C 的超糾合(或 C 是 C++ 的子集),或,C++
                                                                               
並且,事實不只如此,可以說,幾近在每一個處所,C++ 都全面超越了 C(
是事實。                                                                               
                                                                               
   總之,以上所討論的每項特征,都使得 C++ 的程式設計,在基本上就和 C 語言
就更美麗、輕易浏覽、理解,一致性高,就不容易犯錯,利便保護翻譯總之,封裝機制對
一致明確的語法表達、更加具有彈性和擴充性,且更有用率的函式物件(function
                                                                               

為程式設計的思維觀念更前進了,所以又有更嚴密的區隔)。概略地說,前者是指
體組件抱負最主要的第一步。
                                                                               
                                                                               
邁向成熟而完備的語言天然的趨向翻譯
                                                                               
                                                                               
                                                                               
而今朝,泛型編程的手藝在 C++ 上的實現應當也是最成熟的翻譯B.S.(C++的發現人)
                                                                               
                                                                               
  必須迥殊提到一點,C 之所以受很多程式設計師青睞(也同時令另一些人望
篇答複書記中曾討論過,這個說法應當只是指說話自己,而不是指直接透過 C++
,就是:「使用者不應為他沒有效到的功能付出效力的價格」。這句話直接的
                                                                               
                                                                               
                                                                               
                                                                               
  C 及 C++ 是今朝最受迎接的說話之「二」翻譯一般人常常感覺二者差不多,
                                                                               
  4. generic paradigm
 a = "-3298347290354325472309573874327432094739742071561";
常常行止理複雜、過於低階的陣列、指標、位元等等運算(固然有必要時照樣該這麼
                                                                               
                                                                               
                                                                               
  概略地說,C 自己十分精簡,保存字少少,語法簡潔、設計氣勢派頭傾向正確、
                                                                               
所謂周全是指:編譯/聯絡器供應更嚴謹、更安全的查抄,語法表達更一致明白、
                                                                               
                                                                               
  假如翻譯公司熟悉 C,但不熟習 C++,你必然會說:「這怎麼可能?????」但這
也就是 object-based 的基礎,讓程式設計師可以更進一步以嚴謹、平安,自然、
                                                                               
client(利用這些種別的人)而言,是極為便當而不行或缺的,幾近可以說是邁向軟
效率要求的,可謂最「標準」的函式庫 STL(Standard Template Library) 。有了
靈便的編排組織起來翻譯
                                                                               
了生產力。(固然條件是要學得會)
                                                                               
                                                                               
                                                              以上只是個很小的例子,總之,C++ 為了達成兼容效力和彈性的理念,在不
                                                                               
就是支援物件導向的 C。固然,不克不及說這些講法是錯的;是的,這些沒錯,只是
                                                                               
  事實上,C++ 所有不同於 C 的功能,都是為了殺青上述的更嚴謹、安全、一致
                                                                               
而言,都是不成能實現的翻譯並且,透過 C++ 封裝機制和其他如異常處置的支援,
                                                                               
  Essential COM 的作者 Don Box 在書中提到:C++ 個中一個主要的理念,就
                                                                               
面再注釋)
 BigInt sum = 0;
                                                                               
                                                                               
之卻步)的個中一個緣由就在於:C 擁有指標的設計,可以在最大限度的局限內
翻譯公司解決很多小麻煩翻譯另外,如果翻譯公司的 BigInt 種別設計允當,它履行時的效力,
                                                                               
                                                                               
太多太多,每項,都是為了讓程式設計更嚴謹、明白、語法更天然、簡練、一致、
概就是,它困難的程度,也周全超出了 C)(全國沒有白吃的午飯)。翻譯公司應當會想
  int d = 4;
曾暗示,他認為 Java 早晚也會到場雷同 C++ 的 template 的機制,這是任何一個
                                                                               
                                                                               
式--把功能切割成恰當的小模組,在 C 說話中就是一個一個小函式,再按需求
利。以上這段話可能可以當作詮釋「封裝」的註腳,這也就是所謂的 object-based
太不測了。
  b = "458349057395730974539451048634826832629683342310298457";
共同的機制(如 RTTI,動態型別辨識),和在泛型編程的根本上,符合了嚴酷的
                                                                               
                                                                               
  最後,generic paradigm,泛型編程翻譯這是相當晚近才鼓起的程式設計的思惟
                                                                               
又相輔相成的程式設計的思維模式:(因為沒有準確的字面譯詞,先寫英文,後
結(dynamic binding)的機制。
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
  那麼 C++ 到底有何不同呢?用一句最簡單的話說,貫穿 C++ 的全部理念
                                                                               
                                                                                                                    
                                                                               


本文來自: http://blog.xuite.net/edison901/documents/3753230-C+%E5%92%8C+C%2B%2B+%E7%9A%84%E5%B7%AE%E5%88%A5+--有關翻譯的問題歡迎諮詢天成翻譯公司

arrow
arrow
    創作者介紹
    創作者 rodriqpn8jb 的頭像
    rodriqpn8jb

    rodriqpn8jb@outlook.com

    rodriqpn8jb 發表在 痞客邦 留言(0) 人氣()