Wednesday, 29 October 2014

Class declarations and usage in C++ with examples

Class declarations and usage in C++ with examples:

Classes are the user defined data types. The default specifier of the class is private.
A class is blue print of the data type. The memory is not allocated for the class till you declare the object for that.
The definition of the class is defined using the keyword “class” and enclosed with the {};, it should ends with the semicolon as shown above.

Members of the class
The variables which are defined in the class are called as members
Methods of the class
The functions inside the class is called as methods / member functions
Access specifiers
 The class will support three access specifiers “public, private, protected”, the default access specifier is “private”
A constructor is a special function in a class that is called when a new object of the class is created.
A destructor is also a special function, which is called when created object is deleted.
The Copy Constructor
This is also a type of the constructor that is used to create a copy of an existing object of the same class type.
Friend functions
It is one of the key features in c++. Friend functions are used to access the private and protected data of class. When the complier found the keyword friend, it knows the given function is friend function, the complier automatically recognizes that the given function is a friend function.
Inline functions
 These are also functions, but the code is replaced at the compile time which reduces the function calling overhead.

Tuesday, 28 October 2014

C++ Programming examples for beginners

Your First C++ program Structure:

The program is a collection of variables and function calls. The starting point of the program is main (). The primary code for the program starts from the main.

The function definition consist of return type and the list of arguments enclosed with the parenthesis.
In C++ the main function must have the return type of int.

The below is the sample function definition

Monday, 27 October 2014

Basics of C++ with examples

Basics of C++ :

Before going into the programming, You must know almost enough of the basics to create and compile a Program.  The programs that written in C++ will use iostream classes.
These read from and write to files and “standard” input and output.   In this simple program, a stream
object will be used to print a message on the screen.

Escape Sequence:

1. The “\” is an escape character.
2. The “\n” is used to change to a new line
3. The “\t” is used for horizontal tab.
4. The “\r” is used to carriage return – return the cursor to the beginning of current line.
5. The “\a” is an alert. It Sound the system bell.
6. The ‘\\” is used to print out a “\”.
7. The “\”” is used to print out a double quote.

Wednesday, 22 October 2014

Compilers and Interpreters


Compiler is actually a program that reads the code written in high level language and produces a executable that the CPU can understand. To run the executable you will not require the compiler. The below is the way how the compiler processes your high level code into the machine level language  

Introduction to CPP

The is very useful to all the Cpp folks to learn more about C++ programming.
It is not a problem if you do not have the experience in the programming, this Cpp tutorials site will help you to become the master in the CPP. This site will help you to learn more about design in C++ and good programming style.