- Basics of C++
- Structure of a program
- Variables and types
- Basic Input/Output
What is C++?
In 1999, ANSI committee released a new version of C language called C99. It adopted many features which had already made their way into compilers as extensions, or that had been implemented in C++.
Well, that sure is a question, and many people will give you so many answers, but the simplest one is; It is an object-orientated, compiled programming language. If you have never programmed previously, even that answer may be confusing, therefore, let me explain this.
First, the “compiled” part. There are 2 different types of programming languages; compiled languages and interpreted languages. Interpreted languages are run by an aptly-named “Interpreter” program, which reads our program’s code and then executes each command one by one. And Compiled languages, on the other side, are not read by programs at all, but are read by our computer’s CPU. Nevertheless, as some of we may already know, computers can’t read letters. They understand binary numbers only, so first our code must be translated into computer-readable machine code. This process is named as compiling. In a nutshell, an interpreted language is read straight away by a normal program, but compiled language is first translated and then read by the CPU. C++, as I previously mentioned that, It is a compiled language.
Now for the “object-orientated” bit. Simply, this is just the way the code is structured. This will not matter to begin with, so I won’t explain it now. We will be covering it in later chapters.
C++ (pronounced see plus plus) was developed by Bjarne Stroustrup at the Bell Labs, It is an extension to the C, starting in 1979. C++ was ratified in 1998 by the ISO committee, and again in 2003 (called C++03, which is what this tutorial will be teaching). New version of the standard, known as C++ 11 has been made available from 2011 — updates to the tutorial to cover C++11 additions will be made in the supplement.
The underlying design philosophy of C and C++ can be summed up as “ trust the programmer ” — which is both wonderful, because the compiler will not stand in our way if we try to do something unconventional that makes sense, but also dangerous, because compiler won't stand in our way if we try to do something that could produce results that are unexpected. That is one of the primary reasons why knowing how NOT to code C/C++ is important — because there are quite a few pitfalls that new programmers are likely to fall into if caught unaware.
C++ adds many new features to C language, and is perhaps best thought as a superset of C language, though this is not strictly true as C99 introduced a few features that do not exist in C++. C++’s claim to prominence results primarily from the fact that it is an "object-oriented language".
C++ is standardized as ISO/IEC 14882. Currently, there are 2 versions:
- C++98 (ISO/IEC 14882:1998): 1st standard version of C++.
- C++03 (ISO/IEC 14882:2003): minor "bug-fix" to C++98 with no change to the language. Commonly refer to as C++98/C++03 or First C++ standard.
- C++11 (ISO/IEC 14882:2011): 2nd standard version of C++. Formerly called C++0x. It adds some new features to the language; more significantly, it greatly extends the C++ standard library and STL (standard template library).
- C++ is C. C++ supports almost all the features of C. Like C, C++ allows programmers to manage the memory directly, so as to develop the efficient programs.
- C++ is OO (Object Oriented).. C++ enhances the procedural-oriented C language with the object-oriented extension. The OO extension facilitates to design, reuse and maintenance for a complex software.
- Template C++. C++ introduces generic programming, via the pretended template. We can apply the same algorithm to different data types.
- STL. C++ provides a huge set of reusable standard libraries, in particular, the STL (Standard Template Library).
It is a powerful language for high-performance applications, such as writing operating systems and their subsystems, games and animation. C++ is also a complex and difficult programming language, which is really not meant for dummies. Example, to effectively use the C++ STL (Standard Template Library), we need to understand these difficult concepts of: pointers, references, template and operator overloading, on top of the object-oriented programming concepts such as classes & objects, inheritance & polymorphism; and the traditional constructs such as decision and loop. C++ is performance-centric. C++ compiler doesn't issue warning/error message for many obvious programming mistakes, undefined & unspecified behaviors, like using an uninitialized variable, array index out of range, etc, due to the focus on performance and efficiency rather than the ease of use - it assumes that those who choose to program in C++ are not dummies.