How to differentiate two constructors with the same parameters?

Posted by cibercitizen1 on Stack Overflow See other posts from Stack Overflow or by cibercitizen1
Published on 2010-03-15T09:43:56Z Indexed on 2010/03/15 9:49 UTC
Read the original article Hit count: 213

Filed under:
|
|

Suppose we want two constructors for a class representing complex numbers:

Complex (double re, double img)  // construct from cartesian coordinates
Complex (double A, double w) // construct from polar coordinates

but the parameters (number and type) are the same: what is the more elegant way to identify what is intended? Adding a third parameter to one of the constructors?

© Stack Overflow or respective owner

Related posts about c++

Related posts about constructor