1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream> class Bacon { int chunky; public: Bacon() : chunky(42) {} friend int getChunky(Bacon const& b) { return b.chunky; } }; int main() { Bacon b; std::cout << getChunky(b); std::cout << b.getChunky(b); }
1 2 3
In function 'int main()': Line 14: error: 'class Bacon' has no member named 'getChunky' compilation terminated due to -Wfatal-errors.