gcc 4.6.x can't compile original code, it requires syntax: friend class <class name>