Grieve (grieve) wrote,
Grieve
grieve

A C++ quiz

Suppose I gave you the following snippets of code:

#include <cstdio>

void Class::PrintFoo()
{
 printf("Foo\n");
}

int main()
{
   Class13 c13;

   c13.PrintFoo();
   c13->PrintFoo();

   return 0;
}

Now write me the code for Class13, so this would compile, run, and print "Foo" twice. So far 50% of the people I have interviewed have given me the correct answer. For those that have dealt with smart pointers this should be trivial, for everyone else consider that a hint.
Tags: c++, programming
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments