/************************************************
* Name: Some history of C++
* Author: Hualin Li
* Date: 09/02/2015
* Description: This is some Q & A of C++ info.
************************************************/
(1)What two languages most influenced C++ and in what way?
Answer: BCPL and Simula are the two languages most influenced C++. Simula's class concept became an primary focus of the C++ program design. BCPL was able to solve some problems in Simula such as increasing running speed, but makes C look like a very high level language and provides absolutely no type checking
or run time support.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(2)What influence did BCPL have on Stroustrup and his development of C++?
Answer: The simulator wriiten in BCPL did run suitably fast and gave a whole range of useful results that clarified many issues for Stroustrup and provided the basis for several papers on operating system issues.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(3)What are Stroustrup's three crtieria for a programming language?
Answer: <1> would have Simulator support for program organizatation. <2> would produce programs that ran as fast as BCPL programs and share BCPL's ability to easily combine separately compiled units into a program.
<3> should also allow for highly portable implementations.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(4)What is C with Classes? When was it developed?
Answer:The C with Classes began with adding Simula-like features to C, and finally became the early version
of C++. In 1979, a pre-prccessor, called Cpre, was added by Simula-like classes to C. An early discrition ofC with Classes was published as a Bell labs technical report in April 1980.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(5)List the features of C with CLasses that you are familiar with.
Answer: The features are: the class, derived class, strong typing, inlining and default argument.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(6)what was Cpre?
Answer: Cpre is a pre-processor that added Simula-like classes to C running and and in March of 1980 this pre-processor had been refined to the point where it supported one real project and several experiments.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(7)Can you describe the difference between a too and a language? (see if a Google search might help you)
Answer: A language is syntax, grammar, semantics (and perhaps a core library) that implementers are required to support. A tool such as IDE or frameworks either helps one write code or provide are software libraries that provide abstractions of common functions.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(8)What were the design goal(s: and concerns regarding C with Classes?
Answer: The design goal was to add object-oriented programming into the C language, which was and still is a language well-respected for its portability without sacrificing speed or low-level functionality.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(9)What is the key feature of C with Classes?
Answer: The key features included classes, basic inheritance, inlining, default function arguments, and strong type checking in addition to all the features of the C language.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(9)Why was C chosen as one of the inspirational languages for C++? Choose and explain three of Stroustrup's reasons.
Answer: <1> C is flexible. <2> C is efficient. <3> C is available and portable.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(10)C's syntax can get quite convoluted; why didn't Stroustrup improve it??
Answer: The author's eventual rationale for leaving things as they were was that any new syntax would (temporarily at least) add complexity to a known mess. Also, even though the old style is a boon to teachers of trivia and to people wanting to ridicule C, it is not a significant problem for C programmers.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(11)What was Cfront?
Answer: Cfront is the first C with Classes compiler, which was derived from CPre. It was a program designed to translate C with Classes code to ordinary C. Cfront was written mostly in C with Classes, making it a self-hosting compiler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(12)List the features of C++'s initial set of features that you are familiar with.
Answer: Inheritance, encapsulation and overload.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(13)WHy was Stroustrup reluctant to include operator overloading in the language?
Answer: There are four reasons: <1> Overloading was reputed to be hard to implement for compilers <2> Overloading was reputed to be hard to teach and hard to define precisely so that manuals and tutorials would grow to monstrous size. <3> Code written using operator overloading was reputed to be inherently inefficient.
<4> Overloading was reputed to make code incomprehensible.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(14)Why did he then decide to include operator overloading?
Answer: Many users like to have complex numbers, matrices and vectors in C++, they claimed that their code
would become cleaner if they had overloading. Later Stroustrup convinced himself that overloading wasn't inherently inefficient.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(15)What was the motivation behind introducing references?
Answer: References were introduced primarily to support operator overloading. C passes every function
argument by value, and where passing an object by value would be inefficient or inappropriate the
user can pass a pointer. This strategy doesn't work where operator overloading is used. In that
case, notational convenience is essential so that a user cannot be expected to insert address.o f
operators if the objects are large.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(16)C used the functions malloc and free to dynamically allocate memory--the preferred method in C++ is to use the opewrators new and delete. Explain Stroustrup's motivations for this change.
Answer: Long before the first C with Classes program was written, Stroustrup knew that free store (dynamic memory)would be used more heavily in a language with classes than in traditional C programs. This
was the reason for the introduction of the new and delete operators in C with Classes. The
new operator that both allocates memory from the free store and invokes a constructor to ensure
initialization was borrowed from Simula. The delete operator was a necessary complement
because I did not want C with Classes to depend on a garbage collector.
Thus, introducing operator new thus made the use of free store more convenient and less error.
prone.
回到主页
回到目录