C plus plus Notes
Basics of C plus plus
Basics Of OOPs
Classes and Objects
Polymorphism and Inheritence
File Handling and templates
What is the need of Object-Oriented Programming paradigm?
OOP was developed were discovered in earlier approaches of programming. The fundamental idea behind OOP approach was to combine ‘data and functions that operate on that data’ into a single unit called object. It deals with overall organization. In the earlier approaches of traditional programming, few problems arose which were solved by OOP.
Describe the characteristics of OOP.
i. Encapsulation- The wrapping up of data and function into a single unit (called class) is known as encapsulation. It is the most striking feature of a class. OOP encapsulates data (attributes) and functions (behavior) into packages called objects.
ii. Polymorphism- Polymorphism is another important OOP concept. Polymorphism means the ability to take more than on form. An operation may exhibit different behavior in different instances.
iii. Inheritance- Inheritance is the process by which objects of one class acquires the properties of objects of another classes. In OOP, the concept of inheritance provides the idea of reusability.
Define Data Abstraction
Abstraction refers to the act of representing essential features without including the background details or explanation. Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, wait, and cost, and function operate on these attributes.
Define Data members and member functions.
The variables which are declared in any class by using any fundamental data types or derived data type are known as Data Members. The public data members can be accessed using the direct member access (.) operator. A member function of a class is a function that has its definition within the class. Members are accessed using dot (.) operator. Member functions can be defined within the class definition or separately using scope resolution operator (::).
Compare and contrast the structured programming and object.
List and define the two types of Polymorphism.
The two types of Polymorphism are-
1. Run time Polymorphism- If the appropriate member function could be selected while the program is running. This is called run time polymorphism. This could happen due to the fact that C++ supports a mechanism known as virtual function.
2. Compile time Polymorphism- The compiler uses the information from functions and operators at compile time, and, hence, is able to select the appropriate function for a particular call at compile time. This is called early or static binding or static linking or compile time polymorphism.
Define Dynamic Binding.
Binding means matching the function call with the correct function definition by the compiler. When selection of function is done dynamically at run time, it’s called dynamic binding.
Define Message Passing.
An OOP consists of a set of objects that communicate with each other. Message passing involves specifying the name of object, the name of the function (message) and the information to be sent.
What is the return type of main ()?
The return type defines and constrains the data type of the value returned from a method. In many programming languages the return type must be explicitly specified when declaring a function.
Compare and Contrast late binding and early binding.