i am in the process of hiring 2 C++ programmers. This Wednesday 11/18/92
we are cunducting the final interviews with 4 candidates.
I have a C++ question I would like them to address (sort of a programming test, but not really) but I'm not sure if it's too simple or too complex.
I could also use some suggestions on what might be usefull to ask them.
The question follows:
The following program makes use of a class (TestClass) with a static data member (count) that keeps track of the number of instances of the class that currently exist. Suprisingly, however, the output of this program is "1 object(s) currently exist." Why did this happen? What changes can you make to correct the problem?
int getTestClassCount() {return TestClass::count;}
int TestClass::count = 0;
void main() {
TestClass a;
TestClass b=3;
{
TestClass c=a;
}
cout << getTestClassCount() << " object(s) currently exist" << endl;
}
There it is ..... I would guess that many of the people on comp.lang.c++ know the answer. Hint: it has to do with the copy constructor.
I could really use some feedback on what you think about asking this type of question to determine whether someone really knows C++ or whether the've just read some books.
Any other suggestions for what to do during these interviews would be greatly appreciated.
Thanks in advance for any responses before Wednesday.
Eric Taggart
University of California
eric@fs2.assist.uci.edu
P.S. Please feel free to either e-mail or post responses. I will continue to monitor this area for a while. Muchos Gracias. :)