What ctor is z using? I thought I deleted the default/compiler generated one?
Update: Left out g++ warning:
main.cpp: In function 'int main()':
main.cpp:13:41: warning: the address of 'MyClock z()' will always evaluate as 'true' [-Waddress]
cout << x << " " << y << " " << z << '\n';
^
Obviously (I think) the 1 in the program output is from this but... I don't understand what's going on here.
This line: MyClock z();
Is not a declaration of a variable named z, but rather a declaration of a function returning an instance of MyClass and accepting no parameters.
Use the uniform initialization syntax (preferably everywhere), MyClock z{}
or omit the parentheses. MyClock z;
So with the default arguments in MyClock(const uint _minutes = 0, const uint _seconds = 0); the compiler generates a default constructor? I ask because if I do this:
A default constructor is a constructor with no arguments, or a constructor with default arguments provided for every parameter. MyClock(const uint _minutes = 0, const uint _seconds = 0);
Is a default constructor itself.
A default constructor is generated when
a.) you explicitly default it; or
b.) you haven't defined any constructors.
It will not be generated when
a.) you've explicitly deleted it;
b.) you've written it yourself; or
c.) you have defined at least one non-default constructor. (Unless you also explicitly default the default constructor)