Click here to Skip to main content
16,011,374 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need to write a manipulator for class date,
cout << dmy << obj;
it will first print date, month and year. Is there any one cal help me..................?
Posted
Comments
Sandeep Mewara 24-Jul-10 2:07am    
What do you mean by manipulators? Can't you extract them separately and print it?

My questions is about manipulators . DMY is a malipulator, thats i want to write.

i have already over load<< operator...

ostream &operator<<(ostream &out, date d)
{
return out << d.day() << d.month() << d.year();
}
but, cout << MYD << d;
will give the output like month, year & date. MYD is the malipulator i need to write . if you know tell me...

Thanks Mr.Niklas
 
Share this answer
 
Comments
Niklas L 25-Jul-10 5:36am    
You will have to write a manipulator that takes an argument, pretty much like the 'expand' example in the link I gave in my post, and then you will have to use the manipulator like this: cout << MYD(d);
Are you looking for operator overloading? Something like:
C++
ostream &operator<<( ostream &out, const DMY &dmy )
{
  out << dmy.Date() << dmy.Month() << dmy.Year();
  return out;
}


Edit:
maybe I misunderstood your question a bit. Here is a good link to show you how WritingStreamManipulators.html[^]
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900