This should be done, actually, to almost every constructor that can possibly take only one parameter. So that it doesn't act as an implicit conversion operator. Thus, you should not only make date& d non-const on your overload of operator>, you should also mark the constructor explicit, like explicit date(int day=1, int month=1, int year=2000) Two SuperSpeed USB3. This article explains four ways to enable streaming on your iPad or iPhone so you can see your devices content on a television screen. Your problem thus was: this is a call for operator>(istream& stream, const date& d) and you get an infinite recursion. ZEN Stream is a true ground-up design by iFi the hardware and software implementation is quite exceptional. This means the compiler can interpret stream > d.m_day as stream > date(d.m_day). Since it is not marked explicit, it works as an implicit conversion operator for an int (like date(i)). Therefore, it can be called with only one parameter. But here lies the problem: your constructor for date has default values for every parameter. That should have made the compiler simply refuse to compile your function. You defined the function receiving a const &. What is happenning is a bit more complicated: Actually the answer by Marc does not solve your problem completely. Slow Chat: Visual C++: Yesterday, Today, and Tomorrow.Slow Chat: Developing Multithreaded Applications.Slow Chat: Talk with Microsoft Developer Teams.IoT, IoE, and Maker Forum (on VBForums).Project Planning, Design, and Management.Scripting - Server Side (PHP, Perl, etc.). ![]()
0 Comments
Leave a Reply. |