• 2022-06-07
    如下程序声明了一个电话号码类PhoneNumber,重载了流插入运算符<;<;,以便于电话号码的输出。请将程序补充完整。#include<;iostream>;#include<;iomanip>;#include<;string>;using namespace std;class PhoneNumber{public: void setNumber(string number){this->;number=number;}//重载流插入操作符 friend <;span style="text-decoration: underline;">; <;/span>;(ostream &output,const PhoneNumber &num) {output<;<;num.number;return output;}private: string number;};int main(){ PhoneNumber phone; phone.setNumber("8008100598"); cout<;<;"The phone number is:"<;<;phone<;<;endl; return 0;}
  • 举一反三