Search for an elegant and nonintrusive way to access private methods of a class
问题 Disclaimer : This is never meant to be used in production code. It's an exploration at the edges of C++ :) My question is a follow up, based on a discussion with @Johannes Schaub here: calling private methods in c++. I found a very short solution for private member access on his blog: http://bloglitb.blogspot.de/2011/12/access-to-private-members-safer.html Here's a sample: #include <iostream> using namespace std; // example class struct A { A(int a, double b):_a(a),_b(b) { } private: int _a;