#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;
}
格式化输出width,fill
最新推荐文章于 2024-08-04 12:12:02 发布