Basics of C++ Programming

What is C++ ?

is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C programming language, or “C with Classes”. The language has expanded significantly over time, and modern C++ now has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation. It is almost always implemented as a compiled language, and many vendors provide C++ compilers. C++ was designed with an orientation toward system programming and embedded, resource-constrained software and large systems, with performance, efficiency, and flexibility of use as its design highlights. C++ has also been found useful in many other contexts, with key strengths being software infrastructure and resource-constrained applications,including desktop applications, video games, servers (e.g. e-commerce, web search, or databases), and performance-critical applications (e.g. telephone switches or space probes).

Tokens in C++

  1. Identifiers: Identifiers are names given to different elements such as variables,arrays, structures, functions, classes, objects etc.It should not be keywords
  2. Keywords: These are reserved words used for specific purpose in a program. Keywords have fixed meaning, and its meaning cannot be changed.
  3. Constants:
  4. Constants are like a variable, having fixed value . Their value never changes during execution of program once they are defined.
  5. Strings: A sequence or a set of characters is known as a string.
  6. Operators: C++ operator is a symbol that is used to perform mathematical or logical operations.

Keywords in C++

asm continue float new static unsigned
auto default for private struct using
bool delete friend protected switch virtual
break do goto public template void
case double if register this volatile
catch else inline return throw wchar_t
char enum int short try while
class extern long signed typedef
const export namespace sizeof union

Datatypes in C++

Sr. No. Data Type Category Data Types
Built-in Data Types char, wchar_t, int, long, float, double, long double
Derived Data Types Array , Pointer
User-defined data types Structure, Union,  Class and Enumerated
4Data Qualifiers / Modifiers short, long , signed , unsigned

Operators in C++

Sr. No. Type of operators Operators
Arithmetic operators + – * / %
Unary operators – ++ – –
Relational operators < <= > >= == !=
Logical operators ! || && 
Assignment operators = += -= *= /= %=
Conditional operator ? :
Bitwise operators | Bitwise OR & Bitwise AND ^ Bitwise Ex-OR ~ 1’s complement << Shift Left >> Shift Right

Variables in C++

•Variables are the name of memory locations that are allocated by compilers, and
the allocation is done based on the data type used for declaring the variable.

Decision Making Statements in C++

  1. if statement
  2. if-else statement
  3. Nested if-else statement
  4. else-if ladder statement
  5. switch statement

Looping Statements in C++

  1. while statement
  2. do-while Statement
  3. for statement
  4. Nested Loops

Control Statements in C++

  1. break statement
  2. continue statement

Structures in C++

•A set or a group of data items of different data types defined in a single
unit is known as a structure.
•A structure is a convenient tool for handling a group of logically related data items.
•A structure is a user defined data type
•Once the structure type has been defined, it is easy to create variables of that type
using declarations

C++ Compilers

  1. MinGW / GCC
  2. Borland C++
  3. Dev C++
  4. Embracadero
  5. Clang
  6. Visual C++
  7. Intel C++
  8. Code Block