| Other C++ General Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| How to reduce a final size of executable? | | 1 |
| What happens if an exception is throws from an, object's
constructor and object's destructor? | Wipro | 1 |
| What is "mutable" keyword? | | 2 |
| Consider a c++ template funtion
template<class T>
T& Add(T a, T b){return a+b ;}
if this function is called as
T c = Add("SAM", "SUNG");
what will happen? What is the problem in the template
declaration/ How to solve the problem. | Samsung | 4 |
| What is size of null class? | HP | 3 |
| Which of the Standard C++ casts can be used to perform a
?safe? downcast:
a) reinterpret_cast
b) dynamic_cast
c) static_cast
d) const_cast
| Quark | 1 |
| Explain the difference between 'operator new' and the 'new'
operator? | Lucent | 1 |
| What is the difference between static link library and
dynamic link library? | Tech-Mahindra | 1 |
| How to stop conversions among objects? | Symphony | 1 |
| class Alpha {
public:
char data[10000];
Alpha();
~Alpha();
};
class Beta {
public:
Beta() { n = 0; }
void FillData(Alpha a);
private:
int n;
};
How do you make the above sample code more efficient?
a) If possible, make the constructor for Beta private to
reduce the overhead of public constructors.
b) Change the return type in FillData to int to negate the
implicit return conversion from "int" to "void".
c) Make the destructor for Alpha virtual.
d) Make the constructor for Alpha virtual.
e) Pass a const reference to Alpha in FillData
| Quark | 1 |
| when can we use virtual destructor? | HP | 2 |
| Find the second maximum in an array?
| HCL | 2 |
| If P is the population on the first day of the year, B is
the birth rate, and D is the death rate, the estimated
population at the end of the year is given by the formula:
The population growth rate is given by the formula:
B – D
Write a program that prompts the user to enter the starting
population, birth and death rates, and n, the number of
years. The program should then calculate and print the
estimated population after n years. Your program must have
at least the following functions:
1. growthRate: This function takes its parameters the
birth and death rates, and it returns the population growth
rate.
2. estimatedPopulation: This function takes its
parameters the current population, population growth rate,
and n, the number of years. It returns the estimated
population after n years
Your program should not accept a negative birth rate,
negative death rate, or a population less than 2.
| | 1 |
| how to find the maximum of 10 numbers ? | | 3 |
| What are the different operators in C++? | HP | 1 |
| What is the difference between "calloc" and "malloc"? | ADP | 5 |
| Explain the ISA and HASA class relationships. How would you
implement each in a class design? | | 2 |
| catch(exception &e)
{
. . .
}
Referring to the sample code above, which one of the
following lines of code produces a written description of
the type of exception that "e" refers to?
a) cout << e.type();
b) cout << e.name();
c) cout << typeid(e).name();
d) cout << e.what();
e) cout << e;
| Quark | 2 |
| Explain the need for "Virtual Destructor"? | Infosys | 1 |
| What is the difference between a copy constructor and an
overloaded assignment operator? | Microsoft | 3 |
| |
| For more C++ General Interview Questions Click Here |