在现有代码的基础上,使用友元全局函数,让程序能够正常运行。
输入描述:
无
输出描述:
输出年龄
加载中...
#include
using namespace std; class Person { // write your code here...... 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; }