c:c_friend_class
C - C++ Friend Class
#include <iostream> using namespace std; class TwoValues { int a; int b; public: TwoValues(int i, int j) { a = i; b = j; } friend class Min; }; class Min { public: int min(TwoValues x); }; int Min::min(TwoValues x) { return x.a < x.b ? x.a : x.b; } int main() { TwoValues ob(10, 20); Min m; cout << m.min(ob); return 0; }
c/c_friend_class.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1