格式化输出width,fill

来源:互联网 发布:ubuntu 邮件 编辑:程序博客网 时间:2024/06/04 23:19
#include <iostream>using namespace std;class Wf{int w;char f;public:Wf(int w, char f):w(w), f(f){}friend ostream& operator<<(ostream& os, const Wf& o){os.width(o.w);os.fill(o.f);return os;}};int main(){cout << Wf(8,'$') << 123 << endl;return 0;}

原创粉丝点击