Tuesday, 16 December 2014

Introduction to C++| Practical approach to C++

Programming languages basically classified into two types. Those are

1)Procedural Languages(Fortran, Pascal etc)

2)Structural languages(C,C++,Java etc)


 C++ Positives compared to C:

1)C++ works on any environment

2)C++ Provides Security

3)C++ is User Friendly

4)In C, we need to change data types everywhere if we modified at initialization time. It is more time consumption one.

5)Structured Language (C) will not Support for Real Time applications

6)with the help of C++, Complex programs can be implemented in shorter way. So C++ is called feature rich language.

7)with C++ we can implement
        a) better programs
        b)Secured Programs

8) In C++ Minor changes in data types enough.

9) C++ is a Real world situation Platform. That means, Real time applications can be implemented using C++

10) Characteristics of C++

    a) Encapsulation
                Example: class ( along with structure variables, we can able to use the functions which are using those structure variables)

              Encapsulation means Binding data members and member functions using class      
         Class: Class is a collection of data members(in C variables) and member functions (in C functions).


Object Creation in C++:


 Object creation process is called instantiation 


b) Inheritance:  Creating a new class from existing class is called “inheritance”.

C) polymorphism : Names are same but functionality is different. It is called “polymorphism”.

D) Exception Handling: Runtime errors are called Exceptions. Run time problems can be handled by object oriented programming language is called “Exception Handling”.

            Example: If we try to open non-existing file, it generates an error.

E) Templates: C++ supports generic data types. Hence it is called Templates.

F) Persistence: persistence means storing results. This feature is not supported by C++. But supported by Java and .net.

            Persistence means, the previous outputs will also be stored for viewing them next time.

ADA: ADA is a language which supports encapsulation.

Review Questions:
i)                   What is application?
ii)                  What is program
iii)                What are procedural languages?
iv)                What are structural languages?
v)                  Explain differences between procedural languages and structural languages?

G)Delegation: Answer Soon

H)Abstraction:
1) if we don’t know the functionality(coding) of an application, we can’t resolve the
    problem. This concept is called abstraction.
2)Hiding unnecessary details is called data abstraction. Data/ class/ functions can be possible to abstraction(hide).

I) Message passing: passing parameters to the function is called “message passing”
How to view output of compiled code using C++?


         iostream is an object which is already created header file while implementing compiler standard. The class for cout is available in ostream itself.



Here cin is an object. Which is available in istream.

cin means data insertion or data input.

Flexibility:
What is meant by flexibility in C++?


What ever may be the data member(data type) the syntax remains same. This is called flexibility.

In C++, it is possible to access global variables inspite of local variable with same name exists.