⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 [6] big picture issues, c++ faq lite.htm

📁 c++faq。里面有很多关于c++的问题的解答。
💻 HTM
📖 第 1 页 / 共 2 页
字号:

  <LI>C++ 让开发者为软件块提供<A 
  href="http://www.sunistudio.com/cppfaq/classes-and-objects.html#[7.3]">简化的接口<!--rawtext:[7.3]:rawtext--></A>,以改善这些软件块被使用(重用)时的错误率。 

  <LI>C++ 通过<A 
  href="http://www.sunistudio.com/cppfaq/operator-overloading.html#[13.2]">算符重载</A>让你发掘开发者的直觉,降低重用用户的学习曲线。 

  <LI>C++ 将对软件块的<A 
  href="http://www.sunistudio.com/cppfaq/classes-and-objects.html#[7.4]">访问局部化</A>,降低更改时的成本。 

  <LI>C++ 减少<A 
  href="http://www.sunistudio.com/cppfaq/classes-and-objects.html#[7.5]">安全性和可用性的权衡<!--rawtext:[7.5]:rawtext--></A>,改善使用(重用)软件块时的成本。 

  <LI>C++ 减少<A 
  href="http://www.sunistudio.com/cppfaq/inline-functions.html#[9.2]">安全性和速度的权衡</A>,改善错误率而不丧失性能。 

  <LI>C++ 给你<A 
  href="http://www.sunistudio.com/cppfaq/big-picture.html#[6.8]">继承和动态绑定<!--rawtext:[6.8]:rawtext--></A>,以便<A 
  href="http://www.sunistudio.com/cppfaq/big-picture.html#[6.9]">旧的代码调用新的代码<!--rawtext:[6.9]:rawtext--></A>,使得针对市场的快速扩展/调整你的软件成为可能。 
  </LI></UL>
<P><SMALL>[&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/big-picture.html#top">Top</A> |&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/big-picture.html#bottom">Bottom</A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/how-to-post.html">Previous&nbsp;section</A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/classes-and-objects.html">Next&nbsp;section</A> 
]</SMALL> 
<HR>

<P><A name=[6.8]></A>
<DIV class=FaqTitle>
<H3>[6.8] 虚函数(动态绑定)对于 OO/C++来说是主要的吗?<IMG alt=UPDATED! 
src="[6] Big Picture issues, C++ FAQ Lite.files/updated.gif"></H3></DIV><SMALL><EM>[Recently 
inserted "the" before "difference" thanks to <A 
href="mailto:brahms@mindspring.com">Stan Brown</A> and reworded references to 
STL (on 7/00). <A 
href="http://www.sunistudio.com/cppfaq/big-picture.html#[6.11]">Click here to go 
to the next FAQ in the "chain" of recent 
changes<!--rawtext:[6.11]:rawtext--></A>.]</EM></SMALL> 
<P><EM>是的!</EM>
<P>没有<A href="http://www.sunistudio.com/cppfaq/virtual-functions.html">虚函数<!--rawtext:[20]:rawtext--></A>,C++ 
就不是面向对象的了。<A 
href="http://www.sunistudio.com/cppfaq/operator-overloading.html">算符重载<!--rawtext:[13]:rawtext--></A>和非虚成员函数很好,但毕竟,它们只是更典型的C概念中传递一个<TT>struct</TT>的指针给函数的句法装饰而已。虽然<A 
href="http://www.sunistudio.com/cppfaq/class-libraries.html#[32.1]">标准库<!--rawtext:[32.1]:rawtext--></A>包含了许多模板以实现同样非常好的“泛型编程(译注:也称通用编程,"generic 
programming")”技术,但虚函数仍然是用C++进行面向对象编程的核心。
<P>从商业角度看,如果没有虚函数,那么也就没有什么理由要从传统的 C 转移到C++了。(在本 FAQ中我们将忽略泛型编程和<A 
href="http://www.sunistudio.com/cppfaq/class-libraries.html#[32.1]">标准库</A>)。技术人员通常认为在C和非面向对象的C++之间有很大的区别,但如果没有面向对象,这个区别通常不足以证明培训开发者,新工具等的成本是值得的。换句话说,如果我被某个经理征询意见,是否从C转向非面向对象的C++(也就是说,转换语言而不转换典范),那么我可能会劝阻他这样做,除非有逼不得已的面向工具的原因。从商业角度看,面向对象能使系统具有可扩展性和可适应性,但只有C++类的语法而没有面向对象的话,就不会减少维护成本,而实际上会增加培训成本。
<P>底线:没有虚函数的C++不是面向对象。用类编程而没有动态绑定则称为“基于对象”,而不是“面向对象”。踢出虚函数和踢出OO(译注:即面向对象)是一回事。所剩下的就是基于对象编程了,和最初的Ada语言类似(顺便说一下,新的Ada语言支持OO而不是基于对象编程了)。 

<P><SMALL>[&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/big-picture.html#top">Top</A> |&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/big-picture.html#bottom">Bottom</A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/how-to-post.html">Previous&nbsp;section</A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/classes-and-objects.html">Next&nbsp;section</A> 
]</SMALL> 
<HR>

<P><A name=[6.9]></A>
<DIV class=FaqTitle>
<H3>[6.9] 我来自密苏里州。你能给我一个理由,为什么虚函数(动态绑定)造成很大的不同?</H3></DIV>
<P>总体来说:动态绑定能通过使旧的代码调用新的代码来提高重用。
<P>在 OO(译注:即面向对象)之前,重用是通过使新的代码调用旧的代码来完成的。举例来说,程序员可以写一些代码来调用一些重用的代码,如 
<TT>printf()。</TT>
<P>在OO中,重用能够通过使旧的代码调用新的代码来完成。例如,程序员可以写一些代码被非常非常始祖的框架所调用。而不需要修改始祖的代码。事实上,甚至不需要被重新编译。即使源代码已经遗失了25年,你只有目标文件,那个原始的目标文件将会调用新的扩展的代码而不会遗失什么。
<P>这是可扩展性,这是OO。 
<P><SMALL>[&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/big-picture.html#top">Top</A> |&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/big-picture.html#bottom">Bottom</A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/how-to-post.html">Previous&nbsp;section</A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/classes-and-objects.html">Next&nbsp;section</A> 
]</SMALL> 
<HR>

<P><A name=[6.10]></A>
<DIV class=FaqTitle>
<H3>[6.10] C++ 是否向下兼容 ANSI/ISO C?</H3></DIV>
<P>差不多。
<P>C++尽可能地兼容C,但不完全。在实践上,主要的区别是,C++需要原型,<TT>f()</TT>声明一个不带参数的函数(在 C 
中,<TT>f()</TT>和<TT>f(...)</TT>是相同的)。
<P>还有一些非常微小的差别,象在C++中<TT>sizeof('x')</TT>等于<TT>sizeof(char)</TT>,而在 C 
中等于<TT>sizeof(int)</TT>。同样,C++在同一个命名空间中放置结构"tags"作为其他名称,而在 C 
中,需要显式的<TT>struct</TT>(举例来说,<TT>typedef&nbsp;struct&nbsp;Fred&nbsp;Fred;</TT>技巧当然也可以工作,但在C++中是多余的)。 

<P><SMALL>[&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/big-picture.html#top">Top</A> |&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/big-picture.html#bottom">Bottom</A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/how-to-post.html">Previous&nbsp;section</A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/classes-and-objects.html">Next&nbsp;section</A> 
]</SMALL> 
<HR>

<P><A name=[6.11]></A>
<DIV class=FaqTitle>
<H3>[6.11] C++ 标准化了吗?<IMG alt=UPDATED! 
src="[6] Big Picture issues, C++ FAQ Lite.files/updated.gif"></H3></DIV><SMALL><EM>[Recently 
changed "has been finalized" to "was finalized" thanks to <A 
href="mailto:brahms@mindspring.com">Stan Brown</A> (on 7/00). <A 
href="http://www.sunistudio.com/cppfaq/big-picture.html#[6.12]">Click here to go 
to the next FAQ in the "chain" of recent 
changes<!--rawtext:[6.12]:rawtext--></A>.]</EM></SMALL> 
<P>是的。
<P>C++标准被ISO(国际标准化组织)和一些国家标准组织,如ANSI(美国国家标准协会),BSI(英国标准协会),DIN(德国国家标准组织)所定稿和采用。ISO标准在1997年11月14日经投票一致被定稿和采用。
<P>ANSI C++委员会被称为“X3J16”。ISO C++标准小组被称为“WG21”。ANSI/ISO 
C++标准的主要参与者几乎包含了每个人:有来自澳大利亚,加拿大,丹麦,法国,德国,爱尔兰,日本,荷兰,新西兰,瑞典,英国和美国的代表,连同大约一百多个公司的代表和感兴趣的个人。主要参与者包括AT&amp;T,爱立信,Digital,Borland,惠普,IBM, 
Mentor Graphics,微软,Silicon Graphics,Sun 
Microsystems和西门子。经过大约8年的工作,标准完成了。在1997年11月14日,代表们出席了在莫里森镇的投票,标准被一致认可。 
<P><SMALL>[&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/big-picture.html#top">Top</A> |&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/big-picture.html#bottom">Bottom</A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/how-to-post.html">Previous&nbsp;section</A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/classes-and-objects.html">Next&nbsp;section</A> 
]</SMALL> 
<HR>

<P><A name=[6.12]></A>
<DIV class=FaqTitle>
<H3>[6.12] 何处能得到 ANSI/ISO C++ 标准的拷贝?<IMG height=12 alt=UPDATED! 
src="[6] Big Picture issues, C++ FAQ Lite.files/updated.gif" 
width=60></H3></DIV><SMALL><EM>[Recently added URLs to free copies of CD2 (on 
7/00) and total rewrite; changed several URLs thanks to <A 
href="mailto:brhamon@cisco.com">Brian K. Hamon</A> and <A 
href="mailto:garen@wsu.edu">Garen Parham</A> (on 4/01). <A 
href="http://www.sunistudio.com/cppfaq/references.html#[8.4]">Click here to go 
to the next FAQ in the "chain" of recent 
changes<!--rawtext:[8.4]:rawtext--></A>.]</EM></SMALL> 
<P>至少有三种方法得到这份文档的软拷贝: 
<UL>
  <LI>$18 [ANSI出版]:到<A 
  href="http://www.techstreet.com/cgi-bin/detail?product_id=49964" 
  target=OutsideTheFAQ>这一页</A>,下拉选择“PDF file”,点击“Place this in your shopping 
  basket”。 
  <LI>$18 [ANSI出版]:到<A 
  href="http://webstore.ansi.org/ansidocstore/product.asp?sku=ISO%2FIEC+14882%3A1998" 
  target=OutsideTheFAQ>这一页</A>,并点击“Add to Basket”。 
  <LI>$245 [ISO出版]:到<A 
  href="http://webstore.ansi.org/ansidocstore/product.asp?sku=ISO%2FIEC+14882%2D1998" 
  target=OutsideTheFAQ>这一页</A>并且点击“Add to Basket”。 </LI></UL>
<P>注意:ISO文档比ANSI昂贵十倍多,但技术内容是一样的。ISO文档的扉页不同,但技术材料和ANSI文档是一样的。请不要email问我为什么ISO对于基本一样的东西收费这么多,那是ISO的商业决定;你必须向ISO的出版/销售部门认购。 

<P>至少有两种方法得到这份文档的硬拷贝: 
<UL>
  <LI>$175 [ANSI出版]:到<A 
  href="http://www.techstreet.com/cgi-bin/detail?product_id=49964" 
  target=OutsideTheFAQ>这一页</A>,下拉选择“Hardcopy”,并点击“Place this in your shopping 
  basket”。 
  <LI>未知价格 [ANSI出版]:致电 NCITS(National Committee for Information Technology 
  Standards; 国家信息技术委员会;这是以前称为“X3”的组织的新名称)。联系人是 Monica Vega,202-626-5739 或 
  202-626-5738。寻求 FDC 14882文档。准备好支付一些钱——文档当然不是免费的。 </LI></UL>
<P>还有两种潜在的有趣的(并且免费的)文档你也许想看: 
<UL>
  <LI>$0:如果你愿意忍受一份(免费的)无授权的,过期的,并且部分错误的文档,您可以从“委员会草案#2”在<A 
  href="ftp://ftp.maths.warwick.ac.uk/pub/c++/std/cd2/">这里</A>和/或<A 
  href="ftp://ftp.research.att.com/dist/c++std/WP/CD2/">这里</A>得到。 
  <LI>$0:ISO 委员会的新闻稿(<I>不是</I> ANSI 或 ISO 标准的拷贝!) 在<A 
  href="http://www.research.att.com/~bs/iso_release.html" 
  target=OutsideTheFAQ>这里</A>。这份新闻稿对于非程序员来说是易读的。 </LI></UL>
<P><SMALL>[&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/big-picture.html#top">Top</A> |&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/big-picture.html#bottom">Bottom</A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/how-to-post.html">Previous&nbsp;section</A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/classes-and-objects.html">Next&nbsp;section</A> 
]</SMALL> 
<HR>

<P><A name=bottom></A><A href="mailto:cline@parashift.com"><IMG height=26 
alt=E-Mail src="[6] Big Picture issues, C++ FAQ Lite.files/mbox.gif" 
width=89>&nbsp;E-mail the author</A><BR>[&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/index.html"><EM>C++ FAQ Lite</EM></A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/index.html#table-of-contents">Table&nbsp;of&nbsp;contents</A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/subject-index.html">Subject&nbsp;index</A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/copy-permissions.html#[1.1]">About&nbsp;the&nbsp;author</A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/copy-permissions.html#[1.2]">&copy;</A> 
|&nbsp;<A 
href="http://www.sunistudio.com/cppfaq/on-line-availability.html#[2.2]">Download&nbsp;your&nbsp;own&nbsp;copy</A>&nbsp;]<BR><SMALL>Revised 
Apr 8, 2001</SMALL> </P></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -