| Other C++ General Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| 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 |
| what is importance of data sturture in a programming
language? | L&T | 10 |
| Do we have private destructors? | Symphony | 9 |
| what is the size of this class
class size
{
public:
char data1;
double d;
int data2;
char data3;
double data4;
short data5;
};
please explain the padding for these double variables. | | 6 |
| What will happen if I allocate memory using "new" and free
it using "free" or allocate sing "calloc" and free it using
"delete"? | | 2 |
| How can you quickly find the number of elements stored in a
a) static array b) dynamic array ? | Lucent | 3 |
| Please post the model question paper of hal? | | 1 |
| how to find the maximum of 10 numbers ? | | 2 |
| Implement strncpy | | 2 |
| When to use Multiple Inheritance? | | 4 |
| What is the difference between = and == in C? | Intel | 8 |
| How to construct virtual constructor | Symphony | 4 |
| How to implement flags? | Symphony | 1 |
| Can inline functions have a recursion? Give the reason? | | 1 |
| Write the program for fibonacci in c++? | | 3 |
| What is problem with Runtime type identification?
| | 1 |
| 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 |
| why we cant create array of refrences | | 2 |
| int f() {
int I = 12;
int &r = I;
r += r / 4;
int *p = &r;
*p += r;
return I;
}
Referring to the sample code above, what is the return value
of the function "f()"?
a) 12
b) 15
c) 24
d) 17
e) 30
| Quark | 2 |
| tell me about yourself ?i want answer for frehers with
various exasmples? | HCL | 2 |
| |
| For more C++ General Interview Questions Click Here |