C++ Interview Questions
- 0of 0 votes
AnswersHow do you explain the _BASIC_ difference between Java and C++ to your grandmother in 3 simple sentences?
- LLOLer August 18, 2009| Report Duplicate | Flag | PURGE
HCL America Software Engineer / Developer C++ - 0of 0 votes
Answers• Code should be in C or C++ and should be ‘production quality’. I.e. has to check for errors at runtime, and cannot overflow or underflow buffers or corrupt memory.
- Twuu August 09, 2009
• Pls include a paragraph explaining how you would test this:
• Implement a routine that processes packets from the network over a reliable TCP connection:
HRESULT ProcessData(PBYTE pDataBuffer, IN ULONG cbBufferSize)// you need to implement this routine
Information:
typedef struct tag_HEADER
{
ULONG cbTotalPacketLen;
ULONG cbThisChunkLen;
#define FLAG_FIRST_CHUNK_IN_PACKET 1
#define FLAG_LAST_CHUNK_IN_PACKET 2
ULONG flags;
} CHUNK_HEADER;
The format the server sends will be a sequence of PACKETs.
Each packet is broken up into a sequence of one or more CHUNKs. Each Chunk starts with a CHUNK_HEADER.
The first CHUNK in a packet has ‘flags’ field set to FLAG_FIRST_CHUNK_IN_PACKET.
The last chunk that has ‘flags’ FLAG_LAST_CHUNK_IN_PACKET sets.
Chunks in the ‘middle’ of packet will have neither flag set.
A chunk can be any size up to 16384 bytes. A packet can be any size unbounded.
The ‘total’ length of the packet will be cbTotalPacketLen, each chunk in the packet will have this same length set in the chunk header.
The ‘length’ of the current chunk will be always ‘cbThisChunkLen’.
The ProcessData(...) routine will be called many times, with whatever data has arrived from the network. The network is reliable so data will arrive in sequence it was sent. However as this is a TCP stream, not a message there is no guarantee that the call to ProcessData will correspond to a complete chunk. I
That is important point, ProcessData may be called many times for even one CHUNK. And may be called with an arbitrary number of bytes each time ranging from just one byte.
Your goal: with ProcessData(…) is to implement a routine that reads the stream and the CHUNKs and from that reconstructs a _complete_ Packet (i.e. has data from all chunks in the packet). Once a packet is constructed you should pass it to a routine:
HRESULT ProcessPacket(PBYTE pPacketBytes, IN ULONG cbCompletePacketSize); //you do not need to implement this. Just call it EVERY time you have a completed packet.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C++ - 0of 0 votes
AnswersExplain how virtual functions are implemented.
- fuckubloomberg July 26, 2009| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer C++ - 0of 0 votes
AnswersWhat is the difference between using Assignment operator and Copy Constructor?
- optimus July 07, 2009| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer C++ - 0of 0 votes
AnswersWhy do you need the const in a copy constructor? For example, if you have Foo (const Foo &), why do you need the const?
- trojanhorse May 28, 2009| Report Duplicate | Flag | PURGE
Financial Software Developer C++ - 0of 0 votes
AnswersI got phone interviewed with Bloomberg.
1)diff bet class and structure
2)syntax of copy constructor
3)why we need copy constructor?
4)why we need overloaded = operator?
5)signature of overloaded = operator for a class?
e.g. Myclass & operator =(const Myclass &)
6)why & used in return type of = operator ?
7)suppose :class Myclass{ public: Myclass(int a){m=a;}; private : int m; };
a)how will u create an array of objects of Myclass on stack?
- DPS Prog May 15, 2009
b)how will u crete an array of objects on heap?
8)what precautions should be taken to write a class's destructure?
9)what will u do to prevent others from creating more than one instances of ur class?
10)how will u make singleton thread safe?
10.1) what problem may occure with singleton at run time?
11)what is diff between "operator new" and "new" ?
12)what happens if new fails to allocate memory?| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
AnswersConvert a binary search tree to a circular sorted linked list. The highest valued node should point to the lowest valued node at each step.
- prolificcoder April 27, 2009| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test C++ Coding Data Structures Linked Lists - 0of 0 votes
AnswersTest a function that sorts a linked list. You have two pointers head which is the original unsorted list and head1 which is said to be the sorted linked list. Return true if head1 did the sorting correctly and return false if not.
bool testlinkedlistsort(Node *head,Node *head1)
I got the solution correct but messed it up while writing it over the white board :|
- prolificcoder April 27, 2009| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test C++ Coding Data Structures Debugging Testing Linked Lists - 0of 0 votes
AnswersWhat is static method? What is a static initializer?
- ThatDude April 20, 2009| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer C++ - 0of 0 votes
AnswersWhat are the differences between Java and C++? List as many as possible.
- webchic April 06, 2009| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer C++ - 0of 0 votes
AnswersExplain Virtual functions. Explain with code why virtual functions are useful. why would you use a const function?
- ez pz March 20, 2009| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer C++ - 0of 0 votes
Answers1. What does the 'final' key word do in Java?
- Bloomberg Interview February 22, 2009
2. Does C++ provide similar machanism? If not, how would you implement it?| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer C++ - 1of 0 votes
Answers1. What's the difference between a pointer and a reference?
- Bloomberg Interview February 20, 2009
2. What's the difference between a class and a struct?
3. How do you allocate memory in C++? What's the difference between malloc and new?| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer C++ - -4of 0 votes
AnswersHow to implement c++'s class's constructor using the struct in c?
- hyan2008 February 12, 2009| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C++ - 0of 0 votes
AnswersWhat is static?
- Asha February 12, 2009| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 1of 0 votes
AnswersYou are creating a calculator for a second grader kids.
- Daniel Johnson February 07, 2009
Write a function:
int Calculate(char *in)
where char *in is a string that contains an expression like: "1+2" or "-234334-345345" and you return the results accordingly. It is given that there would be two operands and an operator between them.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test C++ Object Oriented Design - 0of 0 votes
AnswersHow do you use the Standard Template Library's std::sort() algorithm to sort an array declared as: int v[1000];?
- Anonymous January 23, 2009| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
Answersstd::vector<std::string>vs;
- Anonymous January 23, 2009
Referring to the container definition above, which one of the following lines of code fills vs with five strings containing the word "hello"?| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
AnswersSomeClass *ptr=SomeClass();
- Anonymous January 20, 2009
SomeClass *ptr=SomeClass;
What's difference,or it's the same?| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
AnswersHow do you keep track of how many objects in given class exist?
- Anonymous January 15, 2009| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
AnswersDifference between C-strings and string class in C++.
- neil turok December 17, 2008| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer C++ - -1of 1 vote
AnswersImplementation of Polymorphism in C++?
- Anonymous October 02, 2008| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 1of 0 votes
AnswersIf you were to implement a garbage collector in C++ how will you do it?
- Amod July 22, 2008| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ Computer Architecture & Low Level - 0of 0 votes
AnswersOnsite Interview (coding test) --
- The Hercules April 04, 2008
Q4) Implement a Singleton pattern as a template such that, for any given class Foo, I can call Singleton<Foo>::instance() & get a pointer to a singleton of type Foo. Assume the existence of a class Lock which has acquire() & release() methods. The implementation should be thread safe & exception safe| Report Duplicate | Flag | PURGE
Automated Traders Desk Software Engineer / Developer C++ Object Oriented Design Threads - 0of 0 votes
AnswerHow do virtual function works in C++? What if the function is not declared virtual?
- one2free December 06, 2007| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer C++ - 0of 0 votes
AnswerWhat are the trade-offs in C++ vs Java?
- Jack April 12, 2006| Report Duplicate | Flag | PURGE
Micron Software Engineer / Developer C++