- Explain which of the following declarations will compile and what will be constant - a pointer or the value pointed at:
- const char *
- char const *
- char * const
- You’re given a simple code for the class BankCustomer. Write the following functions:
- Copy constructor
- = operator overload
- == operator overload
- + operator overload (customers’ balances should be added up, as an example of joint account between husband and wife)
- What problems might the following macro bring to the application?
#define sq(x) x*x
- Consider the following struct declarations:
struct A { A(){ cout << "A"; } }; struct B { B(){ cout << "B"; } }; struct C { C(){ cout << "C"; } }; struct D { D(){ cout << "D"; } }; struct E : D { E(){ cout << "E"; } }; struct F : A, B { C c; D d; E e; F() : B(), A(),d(),c(),e() { cout << "F"; } };
- Anything wrong with this code?
T *p = new T[10]; delete p;
- Anything wrong with this code?
T *p = 0; delete p;
- Explain virtual inheritance. Draw the diagram explaining the initialization of the base class when virtual inheritance is used.
Note: Typical mistake for applicant is to draw an inheritance diagram, where a single base class is inherited with virtual methods. Explain to the candidate that this is not virtual inheritance. Ask them for the classic definition of virtual inheritance. Such question might be too complex for a beginning or even intermediate developer, but any applicant with advanced C++ experience should be somewhat familiar with the concept, even though he’ll probably say he’d avoid using it in a real project. Moreover, even the experienced developers, who know about virtual inheritance, cannot coherently explain the initialization process. If you find a candidate that knows both the concept and the initialization process well, he’s hired. - What’s potentially wrong with the following code?
long value; //some stuff value &= 0xFFFF;
- What does the following code do and why would anyone write something like that?
void send (int *to, int * from, int count) { int n = (count + 7) / 8; switch ( count % 8) { case 0: do { *to++ = *from++; case 7: *to++ = *from++; case 6: *to++ = *from++; case 5: *to++ = *from++; case 4: *to++ = *from++; case 3: *to++ = *from++; case 2: *to++ = *from++; case 1: *to++ = *from++; } while ( --n > 0 ); } }
- In the H file you see the following declaration:
class Foo { void Bar( void ) const ; };
Friday, March 5, 2010
C++ Game Developers Interview Question
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment