a question about conversion constructor

hi:
a RationalNumber class is declared as follows:
1
2
3
4
5
6
7
8
class RationalNumber
{
public:
RationalNumber(int num = 0, int denom = 1) :
numerator(num), denominator(denom) {}
private:
int numerator, denominator;
};

Explain why the RationalNumber constructor is a conversion constructor.

If RationalNumber constructor has two or more arguments and no default values, can it be a conversion
constructor?
Last edited on
we cannot answer your homework questions for you

what don't you understand? do you know what a conversion constructor is?
closed account (zb0S216C)
It's simple. The answer is right in front of you. The only hint I can give you with answering the question is this: Think about how the constructor uses the arguments when a new instance of RationalNumber is created.
1
2
3
4
5
6
int n = 10;
RationalNumber r = n;
/*
 * What's going to happen here?
 * Can we just take an int and assigned it to a RationalNumber?
 */
Topic archived. No new replies allowed.