计算机专业外文翻译--c++的起源一个小的历史_第1页
计算机专业外文翻译--c++的起源一个小的历史_第2页
计算机专业外文翻译--c++的起源一个小的历史_第3页
计算机专业外文翻译--c++的起源一个小的历史_第4页
计算机专业外文翻译--c++的起源一个小的历史_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、.外文原文The Origins of C+: A Little HistoryComputer technology has evolved at an amazing rate over the past few decades. Today a notebook computer can compute faster and store more information than the mainframe computers of the 1960s. Computer languages have evolved, too. The changes may not be as dra

2、matic, but they are important. Bigger, more powerful computers spawn bigger, more complex programs, which, in turn, raise new problems in program management and maintenance. In the 1970s, languages such as C and Pascal helped usher in an era of structured programming,a philosophy that brought some o

3、rder and discipline to a field badly in need of these qualities. Besides providing the tools for structured programming, C also produced compact,fast-running programs, along with the ability to address hardware matters, such as managing communication ports and disk drives. These gifts helped make C

4、the dominant programming language in the 1980s. Meanwhile, the 1980s witnessed the growth of a new programming paradigm: object-oriented programming, or OOP, as embodied in languages such as SmallTalk and C+. Lets examine these C and OOP a bit more closely.The Mechanics of Creating a ProgramSuppose

5、youve written a C+ program. How do you get it running? The exact steps depend on your computer environment and the particular C+ compiler you use, but they should resemble the following steps:1. Use a text editor of some sort to write the program and save it in a file. This file constitutes the sour

6、ce code for your program.2. Compile the source code. This means running a program that translates the source code to the internal language, called machine language, used by the host computer. The file containing the translated program is the object code for your program.3. Link the object code with

7、additional code. For example, C+ programs normally use libraries. A C+ library contains object code for a collection of computer routines, called functions, to perform tasks such as displaying information onscreen or calculating the square root of a number. Linking combines your object code with obj

8、ect code for the functions you use and with some standard startup code to produce a runtime version of your program. The file containing this final product is called the executable code. CAsyncSocketA CAsyncSocket object represents a Windows Socket an endpoint of network communication. Class CAsyncS

9、ocket encapsulates the Windows Sockets API, providing an object-oriented abstraction for programmers who want to use Windows Sockets in conjunction with MFC.This class is based on the assumption that you understand network communications. You are responsible for handling blocking, byte-order differe

10、nces, and conversions between Unicode and multibyte character set (MBCS) strings. If you want a more convenient interface that manages these issues for you, see class CSocket.To use a CAsyncSocket object, call its constructor, then call the Create function to create the underlying socket handle (typ

11、e SOCKET), except on accepted sockets. For a server socket call the Listen member function, and for a client socket call the Connect member function. The server socket should call the Accept function upon receiving a connection request. Use the remaining CAsyncSocket functions to carry out communica

12、tions between sockets. Upon completion, destroy the CAsyncSocket object if it was created on the heap; the destructor automatically calls the Close function. CsocketClass CSocket derives from CAsyncSocket and inherits its encapsulation of the Windows Sockets API. A CSocket object represents a higher

13、 level of abstraction of the Windows Sockets API than that of a CAsyncSocket object. CSocket works with classes CSocketFile and CArchive to manage the sending and receiving of data.A CSocket object also provides blocking, which is essential to the synchronous operation of CArchive. Blocking function

14、s, such as Receive, Send, ReceiveFrom, SendTo, and Accept (all inherited from CAsyncSocket), do not return a WSAEWOULDBLOCK error in CSocket. Instead, these functions wait until the operation completes. Additionally, the original call will terminate with the error WSAEINTR if CancelBlockingCall is c

15、alled while one of these functions is blocking.To use a CSocket object, call the constructor, then call Create to create the underlying SOCKET handle (type SOCKET). The default parameters of Create create a stream socket, but if you are not using the socket with a CArchive object, you can specify a

16、parameter to create a datagram socket instead, or bind to a specific port to create a server socket. Connect to a client socket using Connect on the client side and Accept on the server side. Then create a CSocketFile object and associate it to the CSocket object in the CSocketFile constructor. Next

17、, create a CArchive object for sending and one for receiving data (as needed), then associate them with the CSocketFile object in the CArchive constructor. When communications are complete, destroy the CArchive, CSocketFile, and CSocket objects. CSocketFileA CSocketFile object is a CFile object used

18、 for sending and receiving data across a network via Windows Sockets. You can attach the CSocketFile object to a CSocket object for this purpose. You also can and usually do attach the CSocketFile object to a CArchive object to simplify sending and receiving data using MFC serialization.To serialize

19、 (send) data, you insert it into the archive, which calls CSocketFile member functions to write data to the CSocket object. To deserialize (receive) data, you extract from the archive. This causes the archive to call CSocketFile member functions to read data from the CSocket object.Tip Besides using

20、 CSocketFile as described here, you can use it as a stand-alone file object, just as you can with CFile, its base class. You can also use CSocketFile with any archive-based MFC serialization functions. Because CSocketFile does not support all of CFiles functionality, some default MFC serialize funct

21、ions are not compatible with CSocketFile. This is particularly true of the CEditView class. You should not try to serialize CEditView data through a CArchive object attached to a CSocketFile object using CEditView:SerializeRaw; use CEditView:Serialize instead. The SerializeRaw function expects the f

22、ile object to have functions, such as Seek, that CSocketFile does not have.Using the MFC Source FilesThe Microsoft Foundation Class Library (MFC) supplies full source code. Header files (.H) are in the MFCInclude directory; implementation files (.Cpp) are in the MFCSrc directory. Note  

23、60;The MFCSrc directory contains a makefile you can use with NMake to build MFC library versions, including a browse version. A browse version of MFC is useful for tracing through the calling structure of MFC itself. The file Readme.Txt in that directory explains how to use this makefile.This family

24、 of articles explains the conventions that MFC uses to comment the various parts of each class, what these comments mean, and what you should expect to find in each section. ClassWizard and AppWizard use similar conventions for the classes they create for you, and you will probably find these conven

25、tions useful for your own code.You might be familiar with the public, protected, and private C+ keywords. When looking at the MFC header files, you'll find that each class may have several of each of these. For example, public member variables and functions might be under more than one public ke

26、yword. This is because MFC separates member variables and functions based on their use, not by the type of access allowed. MFC uses private sparingly even items considered implementation details are generally protected and many times are public. Although access to the implementation details is disco

27、uraged, MFC leaves the decision to you.:中文译文c+的起源:一个小的历史过去的几十年计算机技术以惊人的速度得到发展。今天,一个笔记本电脑和20世纪60年代的电脑主机相比,计算的速度更快并且存储更多的信息更多。计算机语言也进化了。可能这些变化不富有戏剧性,但它们是重要的。更大,更强大的计算机产生更大、更复杂的程序,这又反过来,提出在项目管理与维护方面的新的问题在20世纪70年代,像C和帕斯卡等语言帮助传达员进入结构化程序设计阶段。一种哲学带来了一个领域的一些新的指令和规则来满足这些功能。随着定位硬件能力的增强,比如管理硬盘驱动等功能,C+除了提供结构化程序

28、的工具之外,也产生了集成的快速运营的程序。这些功能得C成为20世纪80年代占主导地位的编程语言。与此同时, C语言见证了20世纪80年代的新编程范式:面向对象编程,或者是OOP,体现在语言上例如SmallTalk和c+。让我们验证一下C和OOP的联系更密切。创建一个程序的技术假设你已经写完了一个c+程序。你如何让它运行?确切的步骤取决于你的计算机应用环境和你使用的特定的c+编译器,但他们应该遵循以下步骤进行:1。使用一个文本编辑器来编写某一种类的程序并保存在一个文件中。这个文件构成你的程序的源码。2。编译源代码。这意味着运行一个把源代码翻译成内部语言也叫做机器语言的程序,从而被主机应用。翻译出

29、来的程序文件包括的编译文件也就是你的程序的目标代码 3,把额外的代码与目标代码连接起来。例如,通常使用的c+程序库。一个c+库,包括你的电脑日常运行所需要的目标代码,被称为函数,完成显示屏幕信息或计算一个数值的平方根的任务。把你的目标代码与你使用的目标函数的目标代码和使用一些标准的启动程序的代码结合起来以产生你的程序的运行版本。该文件包含这最后的结果就是所谓的可执行代码。CAsyncSocket一个CAsyncSocket对象代表了一个窗口,一个网络通信的节点。CAsyncSocket类包含Windows Sockets API,为想把Windows Sockets与MFC 结合起来使用的程序

30、员提供了一个面向对象的抽象的工具。这个类是建立在假定你理解网络通信的基础上。你是负责处理相互之间的差异,字节顺序的不同、转换不统一的字符和处理多字节之间的差异并且设置MBCS线。如果你想要一个比较方便的接口来管理你关注的问题,这就需要用到Csocket类。使用一个CAsyncSocket对象,调用它的构造函数,然后用构造函数的功能构造需要的字节套接字,除了已经接受的套接字。对于一个服务器套接字调用监听的子函数,并为接口套接字调用联接函数。服务器套接字的功能是一接收到联接请求就接受请求。使用剩余CasyncSocket函数能够进行套接字之间的交流。工程竣工后,如果是创建对象的析构函数自动的废堆,

31、调用关闭函数。Csocket类CSocket源于CAsyncSocket和套接字窗口的API。一个CSocket对象代表了比CAsyncSocket object更高的更抽象的窗口套接字API。CSocketFile CSocket类和CsocketFile 类 以及Carchive一起工作是为了管理发送和接收的数据。一个CSocket对象也提供阻断,这是与CArchive同步运行的非常关键点。阻断的功能,比如接收、发送,接收自,发送到,接受(都是从CAsyncSocket继承来的),在csoket中不要返回一个WSAEWOULDBLOCK 误差。而且,这些函数将会等到所有的操作都结束。此外,

32、 如果取消阻塞调用被认为是阻塞函数调用的一种,那么原来的调用将会与WSAEINTR的误差一起终止。为了使用一个CSocket对象,又叫构造函数,然后调用是为了创建套接字字节。按后默认的参数的创建一个套接字数据库,但如果你没有利用Carchiv对象,,你可以指定一个参数创建一个数据包。或捆绑到一个特定的端口创建一个套接字服务器端口。使用一个连接套筒连接到一个客户端并且在在客户端和服务器端接受。然后创建一个CSocketFile对象,然后把它和CsocketFile构造函数中的Csocket对象结合起来。其次,创建一个Carchive对象来发送和接收数据(如有必要),然后把这些和Carchive构造的函数中的Csocke

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论