1
C ++ में निजी सदस्य कार्यों को एनकैप्सुलेट करने के लिए मित्र वर्गों का उपयोग करना - अच्छा अभ्यास या दुरुपयोग?
तो मैंने देखा कि ऐसा कुछ करके निजी कार्यों को हेडर में रखने से बचना संभव है: // In file pred_list.h: class PredicateList { int somePrivateField; friend class PredicateList_HelperFunctions; public: bool match(); } // In file pred_list.cpp: class PredicateList_HelperFunctions { static bool fullMatch(PredicateList& p) { return p.somePrivateField == 5; // …