正在加载图片...
还生看整自定义类把的 (++ 例1:电话号码的输入/输出(续) void main(i PhoneNumber phone;∥定义一个对象实例 phone cout < Enter a phone number in the form 025-3493333: "<< endl cin >> phone ∥应用重载的输入运算符读入自定义的类型数据 cout <<" The phone number entered was: <<endl phone<<endl,∥应用重载的输出运算符写出自定义的类型数据 结果: Enter a phone number in the form025-349333 025-3492470 The phone number entered was 025-349-2470例1:电话号码的输入/输出(续) void main( ) { PhoneNumber phone; //定义一个对象实例phone cout << "Enter a phone number in the form 025-3493333: " << endl; cin >> phone; //应用重载的输入运算符读入自定义的类型数据 cout << " The phone number entered was :" << endl << phone << endl; //应用重载的输出运算符写出自定义的类型数据 } 结果: Enter a phone number in the form 025-3493333: 025-3492470 The phone number entered was : 025-349-2470 用户自定义类型的输入/输出
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有