题解 | #友元全局函数#
友元全局函数
http://www.nowcoder.com/practice/4f39f32887b643e8a8dca115df4618de
using namespace std;
class Person {
// write your code here......
friend void showAge(Person &);
public:
Person(int age) {
this->age = age;
}
private:
int age;
};
void showAge(Person& p) {
cout << p.age << endl;
}
int main() {
Person p(10);
showAge(p);
return 0;
}