| Other C++ General Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| What is the difference between method and message? | HP | 2 |
| 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 |
| difference between c and c++? | Infosys | 8 |
| whats the size of class EXP on 32 bit processor?
class EXP
{
char c1;
char c2;
int i1;
int i2;
char *ptr;
static int mem;
}; | Huawei | 4 |
| What is "mutable" keyword? | | 2 |
| What is a "RTTI"? | HCL | 5 |
| Explain the need for "Virtual Destructor"? | Infosys | 1 |
| Find the second maximum in an array?
| HCL | 2 |
| why we cant create array of refrences | | 2 |
| What is problem with Runtime type identification?
| | 1 |
| What happens if an exception is throws from an, object's
constructor and object's destructor? | Wipro | 1 |
| Disadvantages of c++ | | 3 |
| Is there something that we can do in C and not in C++? | Patni | 6 |
| Which uses less memory?
a)
struct astruct
{
int x;
float y;
int v;
};
b)
union aunion
{
int x;
float v;
};
c)
char array[10];
| Quark | 3 |
| class X
{
public:
int x;
static void f(int z);
};
void X::f(int y) {x=y;}
What is the error in the sample code above?
a) The class X does not have any protected members.
b) The static member function f() accesses the non-static z.
c) The static member function f() accesses the non-static x.
d) The member function f() must return a value.
e) The class X does not have any private members.
| Quark | 1 |
| Explain the difference between 'operator new' and the 'new'
operator? | Lucent | 1 |
| what is pulse code modulation?
| Wipro | 1 |
| how to find the maximum of 10 numbers ? | | 3 |
| Give 2 examples of a code optimization? | | 1 |
| Write the program for fibonacci in c++? | | 3 |
| |
| For more C++ General Interview Questions Click Here |