#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
最新推荐文章于 2023-10-08 14:29:04 发布