Notices
Notice: Exam Form BE IV/II & BAR V/II (Back) for 2076 Magh
Routine: BE IV/II & BAR V/II - 2076 Magh
Result: BCE I/II exam held on 2076 Bhadra
Result: All (except BCE & BEI) I/II exam held on 2076 Bhadra
Notice: Exam Center for Barrier Exam (2076 Poush), 1st Part
View All
View Old Questions
Computer Engineering(BCT)
Electrical Engineering(BEL)
Electronics and Communication(BEX)
View All
View Syllabus
Computer Engineering(BCT)
Electrical Engineering(BEL)
Electronics and Communication(BEX)
View All

Notes of Object Oriented Programming [CT 501]

Introduction to C++

Need of C++

- It is very difficult to apply structured programming language like C to solve the complex problem and model the real world problems perfectly.
- To overcome such complexity, the programmers find the need of C++ and then C++ was developed.


Features of C++

1. Namespace

It is used for logical grouping of program elements. It helps to develop large application by different members of the team independently without conflict of identifiers name.


2. Class

It is user defined data types that combines data and function together.


3. Derived class

It is new class formed from existing classes which ensures code reuasbility.


4. Access controller

Private, public and protected keywords control the access of members within the class.


5. Constructor and Destructor

A constructor is used to allocate required memory for members and initialize the objects of its class. It has the same name as of its class.
A destructor complements the operation of constructor. It has same name as of its class but preceded by tilde (~) symbol.


6. Friend function and class

Friend function is used to access even the private members of a class. In other to access hidden members of a class, by another class, the class must be declared as friend class.


7. Reference variable

It is useful to pass arguments by reference.


8. Function Overloading

When same function name is used for different operation, it is called function overloading. It is used to manipulate same nature of problems but with different numbers of arguments.


9. Default argument

Default argument come into action when no any arguments are passed during a function call.


10. Inline function

The function body put directly in the called location to reduce execution time.


11. Operator overloading

It extends the meaning of an operator for user defined type.


12. Easier memory management

C++ provides 'new' operator for dynamic memory allocation and 'delete' operator for dynamic memory deallocation.


13. Stream class library

Header files declare stream class, functions and declarations.


14. Run time polymorphism

The member function of a class can be selected at run time.


15. Exception handling

Exception are the errors during run time.


16. Run time type information (RTTI)

It is mechanism that allows the type of an object to be determined during program execution. The elements of RTTI are dynamic_cast, type id operator and type_info class.


C++ vs C

 

C C++
  1. It was introduced by Dennis Ritchie at AT and T Bell lab.
  2. It follows procedural approach of programming paradigm.
  3. Languages such as C++, perl, PHP are influenced by C.
  4. C program is faster to compile.
  5. It does not support extension in programming.
  6. It provides fewer libraries.
  7. It provides fewer keywords.
  1. It was introduced by Bjarne Stroupstup at AT and T Bell lab.
  2. It follows object oriented approach.
  3. Languages such as JAVA, object oriented PHP are influenced by C++.
  4. C++ program is comparatively slower to compile.
  5. It supports extension like operator overloading, inheritance and so on.
  6. It provides improved and extended libraries.
  7. It provides more keywords.

 


History of C++

- In 1967, Simula and BCPL
- In 1978, B; then K and RC; then Classic C
- In 1980, C with classes
- In 1985, Early C++ , C89
- In 1989, ARM C++
- In 1998, C++ 98, C99

 

 -by SURAJ AWAL

Sponsored Ads