| Other C++ General Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| What compiler was used?
| Intel | 3 |
| 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 |
| what is data Abstraction? and give example | TCS | 13 |
| what is pulse code modulation?
| Wipro | 1 |
| Give 2 examples of a code optimization? | | 1 |
| what is meaning of isa and hsa | | 1 |
| What are the different types of Storage classes? | | 3 |
| Do we have private destructors? | Symphony | 9 |
| What is Name Decoration? | Lucent | 2 |
| In a class, there is a reference or pointer of an object of
another class embedded, and the memory is either allocated
or assigned to the new object created for this class. In
the constructor, parameters are passed to initialize the
data members and the embedded object reference to get
inialized. What measures or design change should be advised
for proper destruction and avioding memory leaks, getting
pointers dangling for the embedded object memory
allocation? Please suggest. | GE | 3 |
| 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 are the differences between public, private, and
protected access? | Wipro | 4 |
| Implement strncpy | | 2 |
| How can you find the nodes with repetetive data in a linked
list? | Lucent | 1 |
| difference between c and c++? | Infosys | 8 |
| implement stack using stack.h headerfile functions | Subex | 1 |
| What is the output of:
String a1 = "Hello";
String a2 = "world!";
String* s1 = &a2;
String& s2 = a1;
s1 = &a1;
s2 = a2;
std::cout << *s1 << " " << s2 << std::endl; | Lehman-Brothers | 4 |
| const char *
char * const
What is the differnce between the above two? | TCS | 8 |
| Write a String class which has:
1) default constructor
2) copy constructor
3) destructor
4) equality operator similar to strcmp
5) constructor which takes a character array parameter
6) stream << operator | Lehman-Brothers | 1 |
| 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 |
| |
| For more C++ General Interview Questions Click Here |