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

  • Python Version

    In regards to this, here is the python version: def initialList(size): return [0 for x in range(size)] def XinY_Go(x,y,index,slots): if (y -…

  • Parallel Computing

    At work the other day Bucky, Kilroy, and I were discussing Parallel computing. I made the comment that all parallel computing was multi-threaded, but…

  • List Comprehensions in python

    veloso had an interesting python puzzle for me in python. How could you take a tuple in python, such as (1,2,3) and transform it into the…

  • 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