The emphasis is on the ideas, constraints, and people that shaped the language of C++, rather than the minutiae of C language features. Key design decisions relating to language features are discussed, but the focus is on the overall design goals and practical constraints. The evolution of C++ is traced from C with Classes to the current ANSI and ISO standards work and the explosion of use, interest, commercial activity, compilers, tools, environments, and libraries. After a while new datatypes, operators and assignment statements and statement level control structures were added to C++ language. – (Thesis)
C++ along with most all other programming languages provide a predefined set of primitive data types. The primitive data types are not defined in terms of other types. The most common primitive data types in C++ are integers, Booleans, and character types. Integers in C++ could also be declared as a float or a double. The float value is a four-byte value, but the double has double the precision of a float by being an sixty four bit value. The selection of a float or a double is important if the application needs to compute something and be extremely accurate. Boolean types in C++ are like just like they are in other programming language. This provides the programmer with the ability to use a true or false value, and only takes up one bit. However, because a single bit of memory cannot be easily retrieved, they are frequently stored as a byte. CITATION Rob l 1033 (Sebesta)The Boolean values are also commonly used as flags or switches. (Sebesta). Character values in defined as type “char”. A character variable in C++ occupies a single byte of memory which contains the numeric code for that character. The code is converted using a numeric coding system, most commonly the ASCII coding system. (Hekmat, 2005).
C++ supports a set of operators for its built-in types. However, most concepts for which operators are used are not built in types, so they must be represented as user defined types. In C++ the programmer can overload a operator such as the +, -, *,/ provided at least one of the arguments is an object of some class. Defining operators for such classes sometimes allows a programmer to provide a more conventional and convenient notation for handling objects than could be achieved using only the basic functional notation. It is very important when a programmer is working in a team environment and using overloaded operators to ensure that they use very effective commenting. It is common for programmers working in a team coding environment to work on code that someone else started and it wouldn’t be easy without proper commenting to understand the overloaded operators. CITATION Bja97 l 1033 (Stroustrup, The C++ Programming Language, 1997)Since C++ is a strongly typed programming language, which means that it requires all variables to be declared a certain data type before being used in the programming. There are times that a variable may need to be converted later on in the program. There are two types of type conversions in C++. The first is implicit type conversion, and the second is explicit type conversion. Implicit type conversions are done automatically by the compiler, and are usually performed on arithmetic operands, function arguments, function return values and initializers. CITATION Pau94 l 1033 (Wang, 1994). Assignment statements in C++ are used to assign a value to a variable. Since C++ is a strongly typed language, the variables have to be assigned a value before they are used in the program. To assign a value to a variable the programmer uses a single equal sign. Because the single equal sign is used for the assignment statement, the programmer must use a double equal sign for arithmetic operation. The double equal sign is also used in relational expressions. Not only can the variable be assigned a single value, but it could be assigned the value of an arithmetic operation.
We Will Write a Custom Essay Specifically
For You For Only $13.90/page!
C++ has two different types of control structures, the selection statement and the iterative statement. There are also two different types of selection statements in C++, the if statement and the switch statement. The if statement is initialized by using the key word “if” followed by parentheses with a relational expression inside the parentheses. If there is just one operation in the if statement, then that operation can be coded directly after the parentheses. If there is more than one operation in the if statement then the block of code must be enclosed by curly brackets. The operation in the if statement is performed when the relational operator returns true. If the statement has an if, and else then the else statement comes last. The switch allows the selection of any number of statements or statement groups. The switch statement consist of a control expression, then case statements with a constant expression inside of each. At the end of the switch statement the programmer can put an optional default statement that is for unrepresented values of the control expression. CITATION Rob l 1033 (Sebesta).
C++ has three different iteration statements, the while loop, the for loop, and the do while loop. A while loop in C++ is similar to an if statement in that it test a condition and if it is true, it does something. The difference is that a if statement only does the operation one time, and the while loop does the operation until the condition becomes false. The for loop in C++ is the most commonly used loop in the language. This loop has a initialization statement, and a condition statement, it also increments or decrements each time through the loop. The initialization statement is executed one time, and the operation statement and update expression execute while the condition remains true. The do loop is used in C++ when the body of the loop must be executed at least one time before the condition of the loop is evaluated. Once the body of the loop is executed one time the condition of the loop will then be tested. CITATION Cay09 l 1033 (Budd, 2009)In conclusion, the C++ language was planned as an improvement on the C programming language, adding features based on object-oriented programming. Step by step, a lot of advanced features were added to the language, like operator overloading, exception handling and templates. It was created for writing programs for many different purposes. In the 1990s, C++ became one of the most used programming languages in the world. Its first name was C with classes, and it was then renamed to C++. REFERENCE
Budd, C. H. (2009). Big C++ 2nd Edition. John Wiley and Sons.
Multithreading with C++ and MFC. (n.d.). Retrieved from MSDN: http://msdn.microsoft.com/en-us/library/975t8ks0(v=vs.80).aspxSebesta, R. Concepts of programming languages (9th ed.). Boston: Addison-Wesley.
Stroustrup, B. A History of C++: 1979-1991. Murray Hill, New Jersey 07974.
Wang, P. S. (1994). C++ with object oriented programming. Internation Thomson Publishing.