Extra Questions
Extra Questions
C C++
C language doesn’t support virtual and C++ language supports both virtual and
friend function friend functions.
You use access modifiers to define accessibility for the class members. It defines how
to access the members of the class outside the class scope.
Private
Public
Protected
The equal to operator == checks whether two values are equal or not. If equal, then it’s
true; otherwise, it will return false.
The assignment operator = allots the value of the right-side expression to the left
operand.
1. -
2. +
3. ?:
4. %
In prefix (++i), first, it increments the value, and then it assigns the value to the
expression.
In postfix (i++), it assigns the value to the expression, and then it increments the
variable's value.
Enumeration: Enum
A member function in the base class redefined in a derived class is a virtual function. It
is declared using the virtual keyword. It ensures that the correct function is called for an
object, irrespective of the type of reference/pointer used for the function call. Virtual
functions are mainly used for runtime polymorphism.
18. What do you understand about friend class and friend function?
A friend class is capable of accessing protected, private, and public members of other
classes in which it is declared as friends.
A friend function can also access protected, private, and public members, but it is not a
member function.
19. What are the three different types of C++ access specifiers?
Public: All member functions and data members are accessible outside the class.
Protected: All member functions and data members are accessible within the class
and to the derived class.
Private: All member functions and data members cannot be accessed outside the
class.
You use the void() return type when you don’t want to return any value. It specifies that
the function doesn’t return a value. A function with a void return type completes its task
and then returns the control to the caller.
In the call by value method, you pass the copies of actual parameters to the function's
formal parameters. This means if there is any change in the values inside the function,
then that change will not affect the actual values.
An inline function when called expands in line. When you call this function, the whole
code of the inline function gets inserted or substituted at the inline function call.
Syntax:
Pointers are the variables that store the memory address of another variable. The type
of the variable must correspond with the type of pointer.
To access a global variable when you have a local variable with the same name.
New Malloc
There is no need to specify memory size while using You have to specify the memory
new() size
For example, you can overload the ‘+’ operator in a class-like string to concatenate two
strings by only using ‘+.’
You can define a friend function as a function that can access private, public and protect
members of the class. You declare the friend function with the help of the friend
keyword. You declare this function inside the class.