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

  • Spell checker's nightmare!

    Ymdn nn xnumzm nn f qdyygj rjmj inkadxzgo omvs wty13. Bcvo rvfjx no owdxfd dx ocj kvho ymvy ocz mtyvynji dx mvsytsgt kqpn adaj tm hdizn kdaj frft…

  • Bar

    V unir gb jevgr 5 cbfgf, ubcrshyyl dhvpxyl, orsber V tb gb orq gbavtug. Guvf jrrx jnf n ebhtu bar, naq V qvq abg xrrc hc jvgu zl cbfg. Onq Tevrir. Gb…

  • 0100001010010110

    111010100001011010100110011101100000010011000110010011101010011010000110001011101001011001110110111001100000010000101110000101101010011011001110101001…

  • 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