miércoles, mayo 02, 2012
I had a C++ phone screen and I thought some people might be interested in seeing the questions that were asked. Here they are:
If you could change one thing about the C++ language, what would you change and why? What are some limitations of c++?
Could you explain to me how virtual functions work? and why you would use them?
What is the overhead of calling a virtual function?
Are there any situations when this overhead is larger or smaller?
When should you make a destructor virtual?
Could you explain to me the difference between static_cast and dynamic_cast?
How would you implement a class that opens two files if you could not use exceptions?
How would you implement that class with two files using exceptions?
How would you handle one of the files failing to open in the case where you have exceptions?
Could your constructor throw an exception after one of the files had been opened and the 2nd one failed? Which destructors would be called in this case? (assumes use of RAII for file handling (which is how I answered the previous questions))
How would you find the 10 most used words used in a large text file (which was a novel)? file -> words -> hashmap
->keep track of top 10 using a vector