OOP

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Procedural() Programming- It is a list of instructions in a single block.

It is suitable for small


programs cause we write everything in a single block.
Modular) Programming- in this program is divided into functions and each function has its
functionality and purpose. But some programmers find this approach difficult to relate with real
world proplems.
OOP- we bind our data and functions together and create a class which is a collection of member
variables and member functions. A class is a blueprint with which we can create an object. This
object is relatable to the real world object. Member functions are capable of using their own
member variables. Class doesn’t occupy any memory in RAM but object does.

Class helps in code reusability. Encapsulation is wrapping up variables and methods in class. It
helps in data hiding. Polymorphism means having different forms. In class method may behave
differently depending on the inputs / function overloading. Inheritance means property of a child
class to inherit the characteristic of a parent class. Abstraction means hiding complicated things
from the user. These are the powerful features pillars ( սյուն)of OOP.
Questions
What’s the difference between C and C++?
1.The first point is C is a procedural or structural programming language. While C++ is procedural &
OOP language.
2.C++ is OOP- class, objects-easy to relate with external world & solving problems.
3.C++ is more secure that C, because it offers security features such as data hiding and
encapsulation. We have access specifiers ( public, private, protected) so that we can control that
what we want to expose (բացահայտել) publicly and what we want to keep private.
4.C++ provides characteristics like inheritance, abstraction, polymorphism, encapsulation, operator
overloading, constructors and many more.
5.C++ is a generic programming language, it’s possible with the help of STL. This library provides
templates.
What is namespace in C++?
If there are two or more functions with the same name defined in different libraries then how will
the compiler know which one to refer to. Hence, we put those functions, class, objects under a
name.
What is using namespace std in C++?
Namespace is nothing but a function. It tells the compiler that you will be making use of the name
space called std. And you want to use all those functions/ classes/ objects under “std”. So that you
don’t need to write std::cout, you can simply write cout , you can directly use the name of
associated function.

You might also like