Monday, 2 January 2017

C++ | VARIABLES | OPERATORS |DECISION MAKING | LOOPING|STORAGE CLASSES|FUNCTION|CLASSES|OBJECTS||INLINE FUNCTION|FUNCTION OVERLOADING|STATIC|INHERITENCE


C++
C++, as we all know is an extension to C language and was developed by Bjarne stroustrup at bell labs. C++ is an intermediate level language, as it comprises a confirmation of both high level and low level language features. C++ is a statically typed, free form, multiparadigm, compiled general-purpose language.

C++ CONCEPTS

VARIABLES

Variable are used in C++, where we need storage for any value, which will change in program. Variable can be declared in multiple ways each with different memory requirements and functioning. Variable is the name of memory location allocated by the compiler depending upon the datatype of the variable.

OPERATORS

Operators are special type of functions, that takes one or more arguments and produces a new value. For example : addition (+), substraction (-), multiplication (*) etc, are all operators. Operators are used to perform various operations on variables and constants.

TYPES OF OPERATORS

1.     Assignment Operator
2.     Mathematical Operators
3.     Relational Operators
4.     Logical Operators
5.     Bitwise Operators
6.     Shift Operators
7.     Unary Operators
8.     Ternary Operator
9.     Comma Operator
DECISION MAKING

Decision making is about deciding the order of execution of statements based on certain conditions or repeat a group of statements until certain specified conditions are met. C++ handles decision-making by supporting the following statements,
·         if statement
·         switch statement
·         conditional operator statement
·         goto statement
LOOPING
In any programming language, loops are used to execute a set of statements repeatedly until a particular condition is satisfied.
TYPES OF LOOPING
1.     while loop
2.     for loop
3.     do-while loop
STORAGE CLASSES
Storage classes are used to specify the lifetime and scope of variables. How storage is allocated for variables and How variable is treated by complier depends on these storage classes.
These are basically divided into 5 different types :
1.     Global variables
2.     Local variables
3.     Register variables
4.     Static variables
5.     Extern variables
FUNCTION

Functions are used to provide modularity to a program. Creating an application using function makes it easier to understand, edit, check errors etc.
CALLING A FUNCTION

Functions are called by their names. If the function is without argument, it can be called directly using its name. But for functions with arguments, we have two ways to call them,
1.     Call by Value
2.     Call by Reference
CLASSES
The classes are the most important feature of C++ that leads to Object Oriented programming. Class is a user defined data type, which holds its own data members and member functions, which can be accessed and used by creating instance of that class.
OBJECTS
Class is mere a blueprint or a template. No storage is assigned when we define a class. Objects are instances of class, which holds the data variables declared in class and the member functions work on these class objects.
INLINE FUNCTION
All the member functions defined inside the class definition are by default declared as Inline. Let us have some background knowledge about these functions.
FUNCTION OVERLOADING

If any class have multiple functions with same names but different parameters then they are said to be overloaded. Function overloading allows you to use the same name for different functions, to perform, either same or different functions in the same class.
Function overloading is usually used to enhance the readability of the program. If you have to perform one single operation but with different number or types of arguments, then you can simply overload the function.
STATIC

Static is a keyword in C++ used to give special characteristics to an element. Static elements are allocated storage only once in a program lifetime in static storage area. And they have a scope till the program lifetime. Static Keyword can be used with following,
1.     Static variable in functions
2.     Static Class Objects
3.     Static member Variable in class
4.     Static Methods in class
INHERITENCE
Inheritance is the capability of one class to acquire properties and characteristics from another class. The class whose properties are inherited by other class is called the Parent or Base or Super class. And, the class which inherits properties of other class is called Child or Derived or Sub class.

No comments:

Post a Comment