| Other C++ General Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| 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 |
| How to implement flags? | Symphony | 1 |
| 1)#include <iostream.h>
int main()
{
int *a, *savea, i;
savea = a = (int *) malloc(4 * sizeof(int));
for (i=0; i<4; i++) *a++ = 10 * i;
for (i=0; i<4; i++) {
printf("%d\n", *savea);
savea += sizeof(int);
}
return 0;
}
2)#include <iostream.h>
int main()
{
int *a, *savea, i;
savea = a = (int *) malloc(4 * sizeof(int));
for (i=0; i<4; i++) *a++ = 10 * i;
for (i=0; i<4; i++) {
printf("%d\n", *savea);
savea ++;
}
return 0;
}
The output of this two programs will be different why?
| | 2 |
| structure contains int, char, float how it behaves for big
endian and little endian? | BITS | 1 |
| Why do C++ compilers need name mangling? | Lucent | 1 |
| 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 |
| Write the program for fibonacci in c++? | | 3 |
| What is "map" in STL? | | 1 |
| Explain the ISA and HASA class relationships. How would you
implement each in a class design? | | 2 |
| What and all can a compiler provides by default? | HP | 3 |
| What are the different operators in C++? | HP | 1 |
| How do you test your code?
| Microsoft | 3 |
| Difference between Top down and bottom up approaches for a
given project ? | HP | 1 |
| What is the Difference between "vector" and "array"? | TCS | 6 |
| What are the basics of classifying different storage types,
why? | Symphony | 1 |
| Why would you make a destructor virtual? | Lehman-Brothers | 3 |
| How to construct virtual constructor | Symphony | 4 |
| What is the difference between public, private, protected
inheritance? | Wipro | 4 |
| How do you know that your class needs a virtual destructor? | Lucent | 3 |
| 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 |
| |
| For more C++ General Interview Questions Click Here |