Thursday, May 1, 2014

ostream Problem

Newsgroup: comp.lang.c++

Subject: ostream Problem

From: mrc2323@...

Date: Thu, 1 May 2014 13:46:07 -0700



I am trying to combine std::left and std::setw() as a single

function. The following code ignores the "left" manipulator. What am I

doing wrong? TIA



struct leftsetw // combined functions (left/width)

{

leftsetw(int w) : width(w) {}

int width;

};

ostream &operator<<(ostream &o, const leftsetw &a)

{

o.left, o.width(a.width);

return o;

}



ostringstream oss;

oss.str(""); oss << "Test " << leftsetw(12) << 42;



---

This email is free from viruses and malware because avast! Antivirus protection is active.

http://www.avast.com









via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://ift.tt/1rUi3oo

View all the progranning help forums at:

http://ift.tt/1dP9txN

No comments:

Post a Comment