home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 353_01 / intro.txt < prev    next >
Text File  |  1992-01-19  |  12KB  |  294 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                                                      Introduction
  8.                                                       WHAT IS C++
  9.  
  10.  
  11. THE ORIGIN OF C++
  12. _________________________________________________________________
  13.  
  14. The C programming language was developed at AT&T for the purpose
  15. of writing the operating system for the PDP-11 series of computers
  16. which ultimately became the unix operating system.  C was developed
  17. with the primary goal of operating efficiency.  Bjarne Stroustrup,
  18. also of AT&T, developed C++ in order to add object oriented
  19. constructs to the C language.  Because object oriented technology
  20. was new at the time and all existing implementations of object
  21. oriented languages were very slow and inefficient, the primary goal
  22. of C++ was to maintain the efficiency of C.
  23.  
  24. C++ can be viewed as a procedural language with some additional
  25. constructs, some of which are added for object oriented programming
  26. and some for improved procedural syntax.  A well written C++
  27. program will reflect elements of both object oriented programming
  28. style and classic procedural programming.  C++ is actually an
  29. extendible language since we can define new types in such a way
  30. that they act just like the predefined types which are part of the
  31. standard language.  C++ is designed for large scale software
  32. development.
  33.  
  34.  
  35.  
  36. HOW TO GET STARTED IN C++
  37. _________________________________________________________________
  38.  
  39. The C programming language was originally defined by the classic
  40. text authored by Kernigan and Ritchie, "The C Programming
  41. language", and was the standard used by all C programmers until a
  42. few years ago.  The ANSI standard for C was finally approved in
  43. December of 1989 and has become the official standard for
  44. programming in C.  Since the ANSI standard adds many things to the
  45. language which were not a part of the Kernigan and Ritchie
  46. definition, and changes a few, the two definitions are not
  47. absolutely compatible and some experienced C programmers may not
  48. have studied the newer constructs added to the language by the
  49. ANSI-C standard.
  50.  
  51.  
  52. This tutorial will assume a thorough knowledge of the C programming
  53. language and little time will be spent on the fundamental aspects
  54. of the language.  However, because we realize that many programmers
  55. have learned the dialect of C as defined by Kernigan & Ritchie,
  56. some sections will be devoted to explaining the newer additions as
  57.  
  58.                                                          Page I-1
  59.  
  60.                                        Introduction - What is C++
  61.  
  62. provided by the ANSI-C standard.  As the ANSI-C standard was in
  63. development, many of the newer constructs from C++ were included
  64. as parts of C itself, so even though C++ is a derivation and
  65. extension of C, it would be fair to say that ANSI-C has some of its
  66. roots in C++.  An example is prototyping which was developed for
  67. C++ and later added to C.
  68.  
  69. The best way to learn C++ is by using it.  Almost any valid C
  70. program is also a valid C++ program, and in fact the addition of
  71. about 12 keywords is the only reason that some C programs will not
  72. compile and execute as a C++ program.  There are a few other subtle
  73. differences but we will save the discussion of them until later.
  74. Since this is true, the best way to learn C++ is to simply add to
  75. your present knowledge and use a few new constructs as you need
  76. them for each new program.  It would be a tremendous mistake to try
  77. to use all of the new constructs in your first C++ program.  You
  78. would probably end up with an incomprehensive mixture of code that
  79. would be more inefficient than the same program written purely in
  80. C.  It would be far better to add a few new constructs to your
  81. toolkit each day, and use them as needed while you gain experience
  82. with their use.
  83.  
  84. As an illustration of the portability of C to C++, all of the
  85. example programs included in the Coronado Enterprises C tutorial
  86. compile and execute correctly when compiled as C++ programs with
  87. no changes.  None of the C++ programs will compile and execute
  88. correctly with any C compiler however, if for no other reason than
  89. the use of the new style of C++ comments.
  90.  
  91.  
  92.  
  93. HOW TO USE THIS TUTORIAL
  94. _________________________________________________________________
  95.  
  96. This tutorial is best used while sitting in front of your computer.
  97. It is designed to help you gain experience with your own C++
  98. compiler in addition to teaching you the proper use of C++.
  99. Display an example program on the monitor, using whatever text
  100. editor you usually use, and read the accompanying text which will
  101. describe each new construct introduced in the example program.
  102. After you study the program, and understand the new constructs,
  103. compile and execute the program with your C++ compiler.
  104.  
  105. After you successfully compile and execute the example program,
  106. introduce a few errors into the program to see what kind of error
  107. messages are issued.  If you have done much programming, you will
  108. not be surprised if your compiler gives you an error message that
  109. seems to have nothing to do with the error introduced.  This is
  110. because error message analysis is a very difficult problem with any
  111. modern programming language.  The most important result of these
  112. error introduction exercises is the experience you will gain using
  113. your compiler and understanding its nuances.  You should then
  114. attempt to extend the program using the techniques introduced with
  115. the program to gain experience.
  116.  
  117.                                                          Page I-2
  118.  
  119.                                        Introduction - What is C++
  120.  
  121.  
  122. In the text of this tutorial, keywords, variable names, and
  123. function names will be written in bold type as an aid when you are
  124. studying the example programs.
  125.  
  126. The way this tutorial is written, you will not find it necessary
  127. to compile and execute every program.  At the end of each example
  128. program, listed in comments, you will find the result of execution
  129. of that program.  Some of the constructs are simple and easy for
  130. you to understand, so you may choose to ignore compilation and
  131. execution of that example program, depending upon the result of
  132. execution to give you the output.  Some students have used these
  133. results of execution to study several chapters of this tutorial on
  134. an airplane by referring to a hardcopy of the example programs.
  135.  
  136.  
  137. DIFFERENT C++ IMPLEMENTATIONS
  138. _________________________________________________________________
  139.  
  140. There are primarily two standards for naming C++ files, one using
  141. the extension CPP and the other using the extension CXX.  All files
  142. in this tutorial use the CPP extension for naming files.  If your
  143. compiler requires the CXX extension it will be up to you to rename
  144. the files.  When C++ was in its infancy, header files generally
  145. used the extension .HPP, but there is a definite trend to use .H
  146. for all header files.  For that reason all header files in this
  147. tutorial will use that convention.
  148.  
  149. Even though we have tried to use the most generic form of all
  150. constructs, it is possible that some constructs will not actually
  151. compile and run with some C++ compilers.  As we find new
  152. implementations of C++, and acquire copies of them, we will compile
  153. and execute all files in an attempt to make all example programs
  154. as universal as possible.
  155.  
  156. The C++ language is very new and is changing rapidly.  The
  157. developer of the language, AT&T, has changed the formal definition
  158. several times in the last few years and the compiler writers are
  159. staying busy trying to keep up with them.  It would be best for you
  160. to search the more popular programming languages for evaluations
  161. and comparisons of compilers.  New C++ implementations are being
  162. introduced at such a rapid rate, that we cannot make a compiler
  163. recommendation here.
  164.  
  165.  
  166. PRINTING OUT THE EXAMPLE PROGRAMS
  167. _________________________________________________________________
  168.  
  169. Some students prefer to work from a hardcopy of the example
  170. programs.  If you desire to print out the example programs, there
  171. is a batch file on the distribution disk to help you do this.  Make
  172. the distribution disk the default drive and type PRINTALL at the
  173. user prompt and the system will print out about 170 pages of C++
  174. programs, all of the example programs in this tutorial.
  175.  
  176.                                                          Page I-3
  177.  
  178.                                        Introduction - What is C++
  179.  
  180. The PRINTALL batch file calls the program named LIST.EXE once for
  181. each example program on the distribution disk.  LIST.EXE was
  182. written in TURBO Pascal and compiled for your use in listing any
  183. program with line numbers and the date and time the program was
  184. last modified.  TURBO Pascal was used because Borland does not
  185. require a licensing fee for distributing copies of the resulting
  186. run time files, and this file is included with all Coronado
  187. Enterprises tutorials.
  188.  
  189.  
  190.  
  191. PROGRAMMING EXERCISES
  192. _________________________________________________________________
  193.  
  194. There are programming exercises given at the end of each chapter
  195. to enable you to try a few of the constructs given in the chapter.
  196. These are for your benefit and you will benefit greatly if you
  197. attempt to solve each programming problem.  If you merely read this
  198. entire tutorial, you will have a good working knowledge of C++,
  199. but you will only become a C++ programmer if you write C++
  200. programs.  The programming exercises are given as suggestions to
  201. get you started programming.
  202.  
  203. An answer for each programming exercise is given in the ANSWERS
  204. directory on the distribution disk.  The answers are all given in
  205. compilable C++ source files named in the format CHnn_m.CPP, where
  206. nn is the chapter number and m is the exercise number.  If more
  207. than one answer is required, an A, B, or C, is included following
  208. the exercise number.
  209.  
  210.  
  211.  
  212. RECOMMENDED ADDITIONAL READING
  213. _________________________________________________________________
  214.  
  215. Richard S. Wiener & Lewis J. Pinson.  "An Introduction to Object-
  216.      Oriented Programming and C++".  Addison-Wesley, 1988.  This
  217.      is the first book recommended since it covers both object
  218.      oriented programming and C++ in depth.  It is clearly written
  219.      and well organized.
  220.  
  221. Brad Cox.  "Object Oriented Programming, An Evolutionary Approach".
  222.      Addison-Wesley, 1986.  This book is excellent for a study of
  223.      object oriented programming and what it is, but since it is
  224.      based on Objective-C, it covers nothing of the C++ language
  225.      or how to use it.
  226.  
  227. Stephen Dewhurst & Kathy Stark.  Programming in C++".  Prentice
  228.      Hall, 1989.  This book covers the fundamentals of the language
  229.      well and covers the proper application of object oriented
  230.      programming techniques.
  231.  
  232.  
  233.  
  234.  
  235.                                                          Page I-4
  236.  
  237.                                        Introduction - What is C++
  238.  
  239.  
  240. Margaret Ellis & Bjarne Stroustrup. "The Annotated C++ Reference
  241.      Manual".  Addison-Wesley, 1990.  This is the base document for
  242.      the ANSI-C++ standard.  Even though it is the definitive book
  243.      on C++, it would be difficult for a beginner to learn the
  244.      language from this book alone.
  245.  
  246. Note that the C++ culture is in rapid change and by the time you
  247. read this, there will be additional well written texts available
  248. as aids to your learning the syntax and proper use of the C++
  249. programming language.
  250.  
  251.  
  252.  
  253. A SPECIAL NOTE FOR THE SHAREWARE VERSION
  254. _________________________________________________________________
  255.  
  256. It is impossible to include the graphics diagrams in chapters 5 and
  257. 7 in a pure ASCII text.  They are therefore omitted from this
  258. version of the tutorial.  If you need these diagrams, they can be
  259. purchased directly from Coronado Enterprises along with your
  260. registration.  See the READ.ME file on either diskette for more
  261. information.
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.                                                          Page I-5