C++ Interview Questions
- 0of 0 votes
AnswersHow to implement inheritance in C?
- chandu December 21, 2010
How to implement Virtual functions in C?| Report Duplicate | Flag | PURGE
Megasoft Software Engineer / Developer C++ - 0of 0 votes
AnswersPhone screen:
- anonymous December 09, 2010
45 minute interview. Horrible experience:
1. How do you call a C library from C++ code and how to you call a C++ library from C code? In the second one, the C++ library only contains pointers and normal function calls, nothing C++ related.
I didn't really know what he was looking for in the second case but then he gave me function overloading as a hint. Then mentioned name mangling.
2. You have an empty class. What does compiler do?
3. What if the class had 1 object? Then he asked if these objects can be sorted? (Sorry, I don't get it either.) When I said you can't sort 1 object then he switched and said an array of objects.
4. Can you sort these objects in the class as a key to a map?
5. What's the sorting order of a map?
6. You have a singly linked list from 1 to 10. and your pointer is pointing to the 5th element. Oh and you don't have a head or tail pointer. Tell me the algorithm to delete this element.
Sorry I don't remember some of the other ridiculous questions. :(| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
Answerswhat are the internal structure of STL's set and map. Why is that so efficient.
- Software Engineer C++ 3+ year exp December 03, 2010| Report Duplicate | Flag | PURGE
Goldman Sachs Developer Program Engineer C++ - 0of 0 votes
AnswerHow to design a connection pool or object pool, How to design a inmemory LRU ( least frequently used ) cache in C++
- Software Engineer C++ 3+ year exp December 03, 2010| Report Duplicate | Flag | PURGE
Goldman Sachs Developer Program Engineer C++ - 0of 0 votes
AnswersPhone interview:
- Anonymous December 01, 2010
45 minute interview... He seemed to have some set of questions but depending on my answers he kept asking more and more. Choose your topics wisely.
Describe a class you wrote.
Have you ever used any designed patterns? If yes, explain what it does and how it is used.
-I picked singleton so he made me explain what is private and public for this class. Why do we need a private constructor?
What is factory method?
This is where "virtual constructor" came up. He asked me if we can have one of those why and why not?
What needs to happen with a base classes destructor? (I think he was trying to get virtual destructors out of me.)
why do we need a virtual destructor?
how do you list the processes on a linux system?
what is context switching?
how do 2 threads communicate/share info?
what's a virtual table?
given map, hash table and linked list, which one is the fastest for seaching?(seach complexity)
how does a hash table work?
how does map work?| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer C++ - 0of 0 votes
AnswersWhat member function are given by compiler if we are not defined in the class?
- Chandra Sekhar November 30, 2010| Report Duplicate | Flag | PURGE
Megasoft Software Engineer / Developer C++ - 0of 0 votes
AnswersWhat is conversion operator?
- Chandra Sekhar November 30, 2010| Report Duplicate | Flag | PURGE
Megasoft Software Engineer / Developer C++ - 0of 0 votes
AnswersWhat is conversion constructor?
- Chandra Sekhar November 30, 2010| Report Duplicate | Flag | PURGE
Megasoft Software Engineer / Developer C++ - 0of 0 votes
AnswersClass B
- sekhar740 November 29, 2010
{
Public:
Void disp();
Void show();
};
Class D : public B
{
Public:
Void disp();
Void show(D &);
};
int main()
{
B *b = new D();
b->disp();
b->show()//base clas show will be called
*/b->show(D)how call derive class show? */
}
how to call Derived class show function with base class pointer?| Report Duplicate | Flag | PURGE
Nisum Technologies C++ - 0of 0 votes
Answersclass Sample
- sekhar740 November 29, 2010
{
public:
Sample() { cout<<"const"<<endl; }
~Sample() {cout<<"destr"<<endl;delete this; }
};
int main()
{
Sample *obj = new Sample;
delete obj;
return 0;
}
what happens when u delete this in destructor?| Report Duplicate | Flag | PURGE
Nisum Technologies C++ - 0of 0 votes
AnswersHow do you avoid dangling pointers and dangling references? Can you have a const reference to an object i.e. MyClass& const refToObj;? Does having a const* to an object guarantee safety from seg faults? What is the best alternative?
- Synonymous November 24, 2010| Report Duplicate | Flag | PURGE
Bloomberg LP C++ - 0of 0 votes
AnswersWhat is a dangling reference? Give sample code.
- Aynonymouse November 24, 2010| Report Duplicate | Flag | PURGE
Bloomberg LP C++ - 0of 0 votes
AnswersWhy does the following code throw segmentation fault?
- Synonymous November 24, 2010 in United Statesint main(){ int myArray[10] = { 1, 2 }; delete[] myArray; }
| Report Duplicate | Flag | PURGE
C++ - 0of 0 votes
AnswersFind the most populous character in a string? Most optimal solution is desired.
- Richa Aggarwal November 12, 2010| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
AnswersFind 2 smallest numbers in an array?
- Richa Aggarwal November 12, 2010
Use of Static in C++.| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
AnswersUse of extern.
- Richa November 10, 2010
Use of static.| Report Duplicate | Flag | PURGE
F5 Networks Software Engineer / Developer C++ - 0of 0 votes
AnswersGive several examples that static class function is useful.
- zhujj04 October 26, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer C++ - 0of 0 votes
Answersconst char *myfunc()
- Reddy October 21, 2010
{
string str("return this");
return str.c_str();
}| Report Duplicate | Flag | PURGE
Software Engineer / Developer C++ - 0of 0 votes
AnswersWhat is the output of the following?
- Reddy October 21, 2010
unsigned short us = 6;
unsigned short us1 = 7;
unsigned short us3 = 8;
printf(?%d\n?, us & 0x00 );
printf(?%d\n?, us | 0xFF );
printf(?%x\n?, ( us & us1 ) | us3 );
printf(?%d\n?, ( ( us << 2 ) & us1 ) | us3 );*/| Report Duplicate | Flag | PURGE
Software Engineer / Developer C++ - 0of 0 votes
AnswersReverse a 4 digit number in one statement. Ex: int n =1234; x= <your code>; cout<<x; //Output: 4321
- Reddy October 21, 2010| Report Duplicate | Flag | PURGE
Software Engineer / Developer C++ - 0of 0 votes
AnswersDescribe the singleton pattern - its purpose and implementation.
- igor October 21, 2010| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer C++ - 0of 0 votes
AnswersWhat things should you take into account when you are planning to use multiple threads in your program. And the one connected to this was: What is deadlock and how do you prevent it?
- igor October 21, 2010| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer C++ - 0of 0 votes
AnswersExplain what is Overloading and overriding.
- igor October 21, 2010| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer C++ - 0of 0 votes
AnswersWhat is polymorphism? Give an example.
- igor October 21, 2010| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer C++ - 0of 0 votes
AnswersWhat is STL auto_ptr? How do you use it and what problems should you be aware of when using it.
- igor October 21, 2010| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer C++ - 0of 0 votes
AnswerDescribe smart pointer and how would you implement it.
- igor October 21, 2010| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer C++ - 0of 0 votes
Answer1. Implement ReverseLinkedList(Node* n).
- Cartman October 19, 2010| Report Duplicate | Flag | PURGE
Software Engineer / Developer C++ - 0of 0 votes
AnswersThis is my biggest doubt, i feel people keep different ideas. The question is:
- Dilip October 17, 2010
Does constructor return anything? Yes/No. Justify.
Any person who has really done some research on that, let me know it. Some technical people think..YES(returns object of same type). some say NO......I feel NO and I have done some research. Please help me.| Report Duplicate | Flag | PURGE
Software Engineer / Developer C++