Introduction - What is C++
The best way to learn C++ is by using it. Almost any valid C program is also a valid C++ program and, in fact, the addition of about 12 keywords is the only reason that some C programs will not compile and execute as a C++ program. There are a few other subtle differences, but we will save the discussion of them until
later. Since this is true, the best way to learn C++ is to simply add to your present knowledge and use a few new constructs as you need them for each new project. It would be a tremendous mistake to try to use all of the new constructs in your first C++ program. You would probably end up with an incomprehensive mixture of code that would be more inefficient than the same program written purely in C. It would be far better to add a few new constructs to your toolkit occasionally, and use them as needed while you gain experience with their use.
As an illustration of the portability of C to C++, all of the example programs included in the Coronado Enterprises C tutorial compile and execute correctly when compiled as C++ programs with no changes. None of the C++ programs will compile and execute correctly with any C compiler however, if for no other reason than the use of the new style of C++ comments.
later. Since this is true, the best way to learn C++ is to simply add to your present knowledge and use a few new constructs as you need them for each new project. It would be a tremendous mistake to try to use all of the new constructs in your first C++ program. You would probably end up with an incomprehensive mixture of code that would be more inefficient than the same program written purely in C. It would be far better to add a few new constructs to your toolkit occasionally, and use them as needed while you gain experience with their use.
As an illustration of the portability of C to C++, all of the example programs included in the Coronado Enterprises C tutorial compile and execute correctly when compiled as C++ programs with no changes. None of the C++ programs will compile and execute correctly with any C compiler however, if for no other reason than the use of the new style of C++ comments.
HOW TO USE THIS TUTORIAL
-----------------------------------------------------------------
-----------------------------------------------------------------
This tutorial is best used while sitting in front of your computer. It is designed to help you gain experience with your own C++ compiler in addition to teaching you the proper use of C++. Display an example program on the monitor, using whatever text editor you usually use, and read the accompanying text which will describe each new construct introduced in the example program. After you study the program, and understand the new constructs, compile and execute the program with your C++ compiler.
After you successfully compile and execute the example program,introduce a few errors into the program to see what kind of error messages are issued. If you have done much programming, you will not be surprised if your compiler gives you an error message that seems to have nothing to do with the error introduced. This is because error message analysis is a very difficult problem with any modern programming language. The most important result of these error introduction exercises is the experience you will gain using your compiler and understanding its nuances. You should then attempt to extend the program using the techniques introduced with the program to gain experience.
After you successfully compile and execute the example program,introduce a few errors into the program to see what kind of error messages are issued. If you have done much programming, you will not be surprised if your compiler gives you an error message that seems to have nothing to do with the error introduced. This is because error message analysis is a very difficult problem with any modern programming language. The most important result of these error introduction exercises is the experience you will gain using your compiler and understanding its nuances. You should then attempt to extend the program using the techniques introduced with the program to gain experience.
The way this tutorial is written, you will not find it necessary to compile and execute every program. At the end of each example program, listed in comments, you will find the result of execution of that program. Some of the constructs are simple and easy for you to understand, so you may choose to ignore compilation and execution of that example program, depending
To Be Continue