0% found this document useful (0 votes)
53 views

Partially Object-Oriented Programming Language

C++ is an object-oriented language that builds upon C with support for classes, objects, inheritance, polymorphism, and operator overloading. Key differences from C include support for classes with data members and member functions, as well as constructs like constructors, destructors, and function/operator overloading. C++ supports both procedural and object-oriented programming approaches.

Uploaded by

Musthafa
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Partially Object-Oriented Programming Language

C++ is an object-oriented language that builds upon C with support for classes, objects, inheritance, polymorphism, and operator overloading. Key differences from C include support for classes with data members and member functions, as well as constructs like constructors, destructors, and function/operator overloading. C++ supports both procedural and object-oriented programming approaches.

Uploaded by

Musthafa
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1. What is the difference between C and C++?

C C++
Procedure oriented programming language Partially object-oriented programming language
Follows top-down approach Follows bottom-up approach
Doesn’t support function or operator Supports Function as well as operator
overloading overloading
Doesn’t support virtual and friend function Supports both
32 Keywords 52 Keywords

2. What are classes and objects in C++?


A class is a user defined data type with data members and member functions and is defined
with the keyword class

Objects are defined as an instance of a class once the object is created, then it can operate
on both data members and member functions.

3. What are access modifiers?


Access modifiers are used to define accessibility for the class members. It defines how the
members of the class are accessed outside the class scope

Private – within class, Public – within package and protected – within derived classes

4. What are C++ OOPS Concepts?


Object
Class
Inheritance
Polymorphism
Encapsulation
Abstraction

Inheritance – Process in which child class inherits all properties and behaviour of parent
class. Inherited class is called base class and the class which inherits is called derived class

Polymorphism – Ability to give different meanings to same function. Allow us to redefine a


function and create it with a completely new definition

Encapsulation - Binding code and data together into a single unit

Abstraction - Hiding the internal details for simplicity and showing the functionality to the
user

5. While Loop and Do While Loop

While loop verifies the condition, if it’s true Do while loop first iterates the loop body
then it iterates the loop till the condition once then it checks for the condition
becomes false
if the condition in while loop false, then not Body will execute once
a single statement will execute inside the
loop

6. What is a Constructor?
A constructor is a member function that is invoked whenever we execute an object, it has
the same name as that of class

 Default Constructor – Don’t take any argument


 Parameterized Constructor – we can pass argument

7. What is operator overloading and function overloading?

 Operator Overloading – Allows operators to have an extended meaning apart from


their predefined meaning or is a mechanism in which a special meaning is given to
an operator. e.g. + used for string concatenation
 Function Overloading – Defines a method in such a way that there are multiple ways
to call them

8. Can We compile a program without main() function??


YES, We can compile. But cannot run or execute the program bcz main function is the
starting point from where all the execution begins

9. Call by value and Call by reference?


 Call by Value – We pass copies of actual parameters to the functions formal
parameter, so if any change happens inside the function won’t effect the actual
values
 Call by Reference- the reference or address of actual parameters is sent to the
functions formal parameter, so any change inside the function will affect the actual
values.

10. Inline function


The inline function is expanded in line when it’s called. When this function is called the
whole code of the inline function gets inserted or substituted at the inline function call

Inline return-type function-name(parameter){


}

11. Pointers in C++


Pointers are variables that hold the memory address of another. type of variable must
correspond with type of pointer

12. Scope Resolution Operator (::)


This operator is used to associate function definition to a particular class
Used for
 To access a global variable when we have a local variable with the same name
 To define function outside the class
13. Differentiate between new() and malloc()

New is an operator Malloc is a function


It calls the constructor Doesn’t call the constructor
No need to specify the memory size Need to specify the memory size
Can be overloaded Can never be

14. STL – Standard template library


It’s a library of container template, that provides generic classes and functions

STL components are containers, algorithms, iterators and function objects

15. What is Friend Function?


A function that can access private, public and protected members of the class. Declared
using friend keyword.

16. Copy Constructor


A copy constructor is a member function that initialises an object using another object with
the same class

 Default copy
 User defined copy

You might also like