操作器的使用

来源:互联网 发布:mac文明 编辑:程序博客网 时间:2024/06/13 03:37

作者:张煜

×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

#include<iostream>#include<iomanip>//在此处引入了iomanip头文件,其中包含有setw()函数的声明using namespace std;int main(){int Basic = 950, Allowance = 95, Total = 1045;cout << setw(10) << "Basic" << setw(10) << Basic << endl<< setw(10) << "Allowance" << setw(10) << Allowance << endl<< setw(10) << "Total" << setw(10) << Total << endl;//setw是对于下一个<<插入进来的需要打印的数据来讲的return 0;}
//我们也可以编写自己的操作器://这是一个头文件的编写:#include<iostream>using namespace std;ostream & symbol(ostream& output)//symbol是新的操纵器,它是 Rs 的表达式。需要显示字符串 Rs 时,可随时使用标识符symbol{return output << "\tRs";}




如需转载请声明原创地址:http://blog.csdn.net/u012485183/article/details/18308527

0 0
原创粉丝点击