Docstoc

cpp

Document Sample
cpp Powered By Docstoc
					                                                C++
A.   History of C and C++
     1.      C Programming language was developed from 1969-1973 at Bell labs, along with the
             UNIX operating system.
     2,      C was a direct descendant of the language B, which was a typeless language developed
             by Ken Thompson as a systems programming language for the fledgling UNIX operating
             system.
     3.      B, in turn, descended from the language BCPL (Basic Combined Programming
             Language), which was designed in the 1960’s by Martin Richards while at MIT.
     4.      In 1971 Dennis Ritchie at Bell Labs extended the B language (by adding types) into what
             he called NB, for “New B”. Ritchie credits some of his changes to language constructs
             found in Algol68. After restructuring the language and rewriting the compiler for B,
             Ritchie gave his new language a name “C”.
     5.      C++ was written by Bjarne Stroustrup at Bell Labs during 1983-1985. C++ is an
             extension of C. Prior to 1983, Bjarne Stroustrup added features to C and formed what he
             called “C with Classes”. He had combined Simula’s use of classes and object-oriented
             features with the power and efficiency of C. The term C++ was first used in 1983.
     6.      Today, C++ is used more than any other language in the development of applications.
B.   Object-Oriented Programming (OOP)
     1.      OOP describes a class as a combination of data and behavior. An object is an instance of
             a class. The data are the class data fields, data members, or attributes of an object. The
             behavior of an object is defined using class functions or operations.
     2.      OOP is more advantageous for large programs than for small programs.
     3.      OOP allows for better cohesion. Cohesion is a description of how tightly related the data
             and operations of a particular class are. High cohesion is desirable.
     4.      OOP allows for less coupling. Coupling describes the interface between a called function
             (the server) and the calling function (the client). It is desirable to have as little coupling
             between functions (and classes) as possible, so that changes in the design of one class do
             not propagate throughout the program, necessitating changes in other classes. Low
             coupling is desirable.
     5.      OOP allows for increased information hiding and data encapsulation. The actual data of
             an object should be contained as a single unit. This is data encapsulation. The data
             however, should not be available to the “outside world.” This is information hiding.
             Why should we hide information? Experience shows that the design of data and data
             structures is more volatile and amenable to change than the design of operations that are
             perform on the data. High levels of information hiding and data encapsulation are
             desirable.



                                             Page 1 of 3
     6.      OOP allows the programmer to design complex classes using less complex classes as
             building blocks. This feature goes by many names, some of which are hierarchy,
             aggregation, composition and inheritance.
     7.      OOP provides a more elegant means of identifying (naming) the data and the operations
             associated with each class of objects.
C.   Characteristics of C++
     1.      C++ is a superset of C. This is why C++ contains features that are inconsistent and
             sometimes irritating.
     2.      C++ can be performance-oriented. That is why there is no run-time error checking. That
             is why it contains low-level operators that emulate assembly language instruction and
             allows the programmer to control computer resources, such as registers, ports, and flag
             masks.
     3.      C++ contains high-level language features, such as loops, conditional processing,
             different data types, arrays, structures, and dynamic memory allocation.
     4.      C++ allows for elegant and aesthetic code.
     5.      C++ is portable at the source code level. Portability is achieved through standardization
             of the language.
D.   C and C++
     1.      Similar to C, C++ is token oriented and case sensitive.
     2.      Similar to C, C++ has only a few basic numeric types.
     3.      Similar to C, C++ supports data aggregation into composite types: arrays, structures,
             unions, enumerations.
     4.      Similar to C, C++ supports a standard set of flow control components such as for loops,
             while loops, do loops, if constructs, switch constructs, and jumps (break, continue, and
             goto).
     5.      Similar to C, C++ is block structured. Similar to C, C++ functions cannot be nested.
             Similar to C, C++ functions can be placed in one file or in many files. Similar to C, C++
             functions can be called recursively.
     6.      Similar to C, C++ is a strongly typed language. It is an error to use an object of one type
             where an object of another type is expected. This is especially true for the arguments of a
             function.
     7.      Even more so than C, C++ is a weakly typed language (yes, both strongly and weakly).
             Conversions between numeric (and even character) types are done silently in both
             expressions and arguments.
     8.      C++ inherits the use of pointers from C for three reasons: a) for passing parameters “by
             reference” from a calling function to a called function, b) for dynamic memory allocation




                                            Page 2 of 3
      on the computer heap (for dynamic structures such as linked lists), c) for manipulating
      arrays and array components.
9.    Similar to C, C++ is designed for efficiency. Arrays bounds are neither checked at
      compile time nor run time. Even more so than C, C++ can be VERY inefficient.
10.   Similar to C, C++ is designed for writing terse code.
11.   Similar to C, C++ is designed for experienced programmers. Compilers are designed not
      to second guess the programmer. C and C++ assume that programmers know what they
      are doing.
12.   Unlike C, C++ adds support for OOP (see section B above).
13.   Similar to C, C++ has a standard library, although the C++ library is much larger and
      much more powerful than the C library.




                                     Page 3 of 3

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:3
posted:10/21/2011
language:English
pages:3