Quote:Original post by Bregma
Quote:Original post by bballmitch
umm...I see how that works, but I can't think of ANY situation where that would be useful. :(
How about this.
struct Point{ Point(double x, double y) : m_x(x), m_y(y) { } double m_x; double m_y;}Point origin(0, 0);
Wouldn't you be surprized if that didn't compile?
I would have been surprised if that compiled, since no constructor is made for type double! I did not know that was possible. I would be less surprised, in this shown case though, since I can understand implicit casting from int to double. But from a POD (plain old datatype) to an
object, via a constructor, I was surprised.
By the way, I believe this property may only be "nested" a couple times (only a couple constructor levels down). I haven't tested it, it's just whaty I heard from my source.
@Anonymous Poster: Yep, that 'explicit' keyword is good to know! Thanks to the posters here for letting me know about it!