WHAT IS C++?
C++ is an object oriented, compiled, low-level, reasonably portable programming language. It's based on C, and it maintains C's syntax. If you're going to learn C++, you'll do very well to have a grounding in C first, or to take a course that covers the relevant C syntax as well as the C++ extensions.
First and foremost, you'll find the headlines telling you that C++ is Object Oriented.
When you write your first program, you'll write a few lines of code to perform a task and it'll work well for you. As you develop onwards to more complex programs, you'll find that you're repeating sections of code (through cut and paste) and that it's a much better idea to name these sections or blocks of code so that you can simply call them up again by name. Fairly soon, you'll find yourself moving these blocks of code out into separate source files so that you can use the same logic elements from one program to the next.
Name blocks of code in this way give you:
- Code re-use to cut down on development and maintenance time.
- Consistency across applications that make your code more
user-friendly and less liable to show up obscure bugs.
The approach of having named blocks of code right across your suite of applications, with each code block performing a specific single task, is known as structured programming. It's streets ahead of single-block code. HOWEVER:
- As your code grows further, you can end up with conflicts
between blocks of code that happen to have been given the
- You would prefer a system where you're encouraged to group
all the bits of code that deal with one data type in one place.
That way, you'll know you have just one area to update and
maintain as your data formats or user requirements change.
- You would like a mechanism where you can easily say that one
type of data and its blocks of code are based on another, and
just describe the changes in a file.
- You would like to be able to forget what goes on at the low
level of the code when you're writing at a higher level, and
just know what you need to put in, what the effects are and
what you get out.
In turning your design inside out from a structured program by thinking of the data aspects first rather than the code aspects, it turns out you can have all these benefits and more. At the expense of a few surprises early on, as your project grows in size, it turns out to be very extensible under object orientation.
C++ is a compiled language. You write a source code file using any editor that you find convenient and that can produce a plain text file output, and you save that file.
You run the source code file through a compiler, and that produces an object file which is a snippet of binary code suitable for your target computer architecture and operating system.
The object file itself is not a complete application. You then need to use a loader/ linker/taskbuilder to roll it in with all the other pieces of code, both yours and standard pieces from the library, before you come up with the final executable file.
C++ is often described as a low-level language in that you have the full control as you code over how memory is allocated, and you can program down to a bit/byte/ register level if you wish. For some applications where performance is paramount, this is exactly what you want. For other applications where you're rushing to develop the code for use just a few times, C++ won't be the language for you unless you're reusing lots of existing code, and/or you're already very familiar with C++ but you're not skilled in other languages such as VB, Python or Perl.
C++ executable programs are not portable between operating systems/CPU types. And yet I said earlier on that it's "reasonably portable", didn't I?
The portability is at a source code level. It's possible to recompile the same source code under a different compiler, to generate object files and ultimately an executable file for different operating system and hardware combinations.
However, even at the source code level libraries do vary and you need to be careful as you develop code. You'll find that there's a great deal of open source code devel- oped in C++, and that the first stage of installing it onto a target machine is to run a configuration script that looks around the machine and finds out all the compiler details, library details, and more, that it needs to get the configuration right.
So, C++ is portable. But it is not just a case of transferring source and running (as it would be with Perl or Python), nor is it simply a case of having the right virtual machine at hand to handle object files (as it would be with Java).
BASED ON C
The C language has been around for many years, and is the industry standard in which many operating systems have been developed. C is also the language in which many other languages are written. There days, however, actually writing in C has become something of a niche as most applications are now written using the superb tool sets that earlier C authors have been able to provide for us, anything from languages to servers to spread sheets to word processors with macro languages.
Being based on C, and maintaining compatibility with it, has made some of the elements of C++ quite complex. Decisions to include multiple inheritance and certain other features in C++ haven't helped to make it quick and easy to learn, and a number of other languages such as C# and Java have been developed by Microsoft and Sun respectively which take much of the intent of C++ but break the C compatibility, simplify, and provide languages which are a little more mainstream and much faster to develop.
See also Training Course - C plus plus Programming