C++ Questions

Q:

What is friend function?

Answer


The function declaration should be preceded by the keyword friend.The function definitions does not use either the keyword or the scope operator :: The functions that are declared with the keyword friend as friend function.Thus, a friend function is an ordinary function or a member of another class.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

2 3662
Q:

What is meant by heap?

A) Used for fast reterival of elements B) Used for organising the elements
C) Both a & b D) None of the mentioned
 
Answer & Explanation Answer: C) Both a & b

Explanation:

A heap is a way to organize the elements of a range that allows for fast retrieval of the element.

Report Error

View Answer Report Error Discuss

Filed Under: C++

2 3633
Q:

What is a container class?

Answer

A class is said to be a container class which is utilized for the purpose of holding objects in memory or persistent media. A generic class plays a role of generic holder. A container class is a good blend of predefined behavior and an interface that is well known. The purpose of container class is to hide the topology for the purpose of objects list maintenance in memory. A container class is known as heterogeneous container, when it contains a set of different objects. A container class is known as homogeneous container when it contains a set of similar objects.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

2 3618
Q:

Where does the exceptions are used?

A) Exceptions are used when postconditions of a function cannot be satisfied. B) Exceptions are used when postconditions of a function can be satisfied.
C) To preserve the program D) none of these
 
Answer & Explanation Answer: B) Exceptions are used when postconditions of a function can be satisfied.

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: C++

1 3604
Q:

Why is it expensive to use objects for exception?

A) Exception object is created only if an error actually happens B) Because of execution time
C) Memory space involved in creating an exception object D) None of the mentioned
 
Answer & Explanation Answer: A) Exception object is created only if an error actually happens

Explanation:

If an error occurs in program, then only exception object is created otherwise, It will not be created. So it’s expensive to use in the program.

Report Error

View Answer Report Error Discuss

Filed Under: C++

1 3599
Q:

What is conversion operator ?

Answer

Class can have a public method for specific data type conversions.
for example:
class B
{
double value;
public  B(int i )
operator double()
{
return value;
}
};
B BObject;
double i = BObject; // assigning object to variable i of type double.
now conversion operator gets called to assign the value.

Report Error

View answer Workspace Report Error Discuss

11 3595
Q:

Where does the allocaters are implemented?

A) Template library B) Standard library
C) C++ code library D) None of these
 
Answer & Explanation Answer: B) Standard library

Explanation:

Allocaters are implemented in C++ standard library but it is used for C++ template library.

Report Error

View Answer Report Error Discuss

Filed Under: C++

1 3586
Q:

What are the advantages of using friend classes?

Answer

- Friend classes are useful when a class wants to hide features from users which are needed only by another, tightly coupled class. 


- Implementation details can be kept safe by providing friend status to a tightly cohesive class.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 3527