Why post this?

Over the past couple of years, I've interviewed a lot of folks for development positions - mostly C++ and COM on Windows. Some people are outstanding, some are truly horrible; but a large number of people seem bright, but just don't have the depth of knowledge that I think a professional C++ developer should have.

What follows is a list of questions that I typically ask interview candidates. No, I'm not going to give you the answers - that's up to you. Someday, you'll be sitting across from me or someone like me, and they'll ask you questions like these.

When that happens, resist the temptation to give a pat, memorized answer. You should be able to take any one of these questions, and talk about each one with an interviewer for at least five minutes or so. The type of candidate that really impresses me is not the one who can answer using the fewest words, it's the one that knows something well, and can explain it to me.

It's very likely that some of these questions might seem unclear, for whatever reason - most likely, my inability to frame them properly in such a constrained format. If you have any comments, or suggestions on how to improve this list, please feel free to contact me at spam@oneparticularharbor.net.

General Questions

These are questions I tend to ask at the beginning or at then end of an interview. There are no right or wrong answers - the intent is to find out more about a candidate, and to get them comfortable talking about themselves.

C++ Questions

Code Snippets

I like to put these up on a whiteboard, and ask questions about them.


What output does the following code generate? Why?
What output does it generate if you make A::Foo() a pure virtual function?

		#include <iostream>

		using namespace std;

                class A {
		public:
			A() {
                                this->Foo();
                        }
			virtual void Foo() {
                                cout << "A::Foo()" << endl;
                        }
		};

		class B : public A {
		public:
			B() {
                                this->Foo();
                        }
			virtual void Foo() {
                                cout << "B::Foo()" << endl;
                        }
		};

		int main(int, char**)
		{
			B	objectB;

			return 0;
		}
	

What output does this program generate as shown? Why?

		#include <iostream>

		using namespace std;

                class A {
		public:
			A() {
                                cout << "A::A()" << endl;
                        }
			~A() {
                                cout << "A::~A()" << endl; throw "A::exception";
                        }
		};

		class B {
		public:
			B() {
                                cout << "B::B()" << endl; throw "B::exception";
                        }
			~B() {
                                cout << "B::~B()";
                        }
		};

		int main(int, char**) {
			try {
				cout << "Entering try...catch block" << endl;

				A	objectA;
				B	objectB;

				cout << "Exiting try...catch block" << endl;
			} catch (const char* ex) {
				cout << ex << endl;
			}

			return 0;
		}
	

Misc. Questions

Additional Links

And finally...

Many thanks to the folks who have pointed out errors or inconsistencies, suggested new questions, and suggested new topics... please forgive me if I've forgotten you: