Thursday, November 24, 2016

C++ STL questions

What are different exception safe containers?
Which is more exception safe list or vector?
Name all standard containers?
How do u sort a list(std::sort requires random access iterators, hence will not work)?
When to use list and vector? (Answer should address complexity, vector contigueness, exception safety and stability of iterators)
What is the last compiler used?
What are weak pointers for?
Why does one use virtual inheritence and private inheritence?



  • Why and when do you need copy constructors? Is there any situation where you want to only implement a copy constructor or an assignment operator but not both?
  • Can you use virtual functions in constructors and destructors? What's going to happen if you try? Why? (this is how it's implemented is unacceptable)
  • If you have a virtual function, do you have to have virtual destructor? Why?
  • Write a code to show "pure virtual function call" runtime error.
  • What is a template? What is template instantiation? What happens if you have a static field in a template class? How does it all work with the linker?
  • Describe how objects are implemented. What is the implementation of virtual functions? How come the compiled code works in descendants? What about multiple inheritance?
  • Why can't you throw exceptions from a destructor?
  • Describe virtual inheritance (it's not the same as virtual functions!)
  • Can you have an array of references? Why not? (this is forbidden by the language is unacceptable)

No comments:

Post a Comment