class FlipFlopReg32
{
int32_t resetValue;
int32_t qCurrent;
int32_t qNext;
public:
FlipFlopReg32(int32_t rv = 0, // default constructor
int32_t c = 0,
int32_t n = 0);
What I'd like to do, is if the 2nd and/or 3rd argument is left off the call to the constructor, qCurrent and/or qNext would take the value of resetValue.
The default constructor is the one that takes no parameters. While your function can have all its parameters omitted to look like it is the default constructor, your code actually doesn't have a default constructor.
OK...I thought I remember my teacher saying otherwise, but I'll take your word for it. I think, though, that with a constructor like this, I don't really need a true default c'tor, do I?
No, you don't need a true default constructor - I just included it to show what I meant. The second constructor in my example can have rv = 0 by default.
@Cubbi: When using functions whose arguments have default values, are you sure the values are not implicitly passed? In that case the constructor is receiving arguments that aren't actually visible in the calling code.
Calling without can argument is different from writing code that does not pass an argument.
Actually, I guess you're right; the this pointer is passed implicitly so even the default constructor is passed an argument...