Hi all,
I'm reviewing some C++ notes and came across this line of code in a section demonstrating copy/assignment constructor use:
The second line in main() makes sense to me because the instance with name 'd' has already been defined.
However, in the first line of main(), what is happening exactly? ? How can an instance of D with name 'd' be initialized with an instance of D also with name 'd'? Chicken or the egg?
Thanks in advance
I'm reviewing some C++ notes and came across this line of code in a section demonstrating copy/assignment constructor use:
Code:
struct D {
int i;
B b1, b2;
};
int main() {
D d = d; // bitwise/memberwise copy
d = d; // bitwise/memberwise assignment
}
However, in the first line of main(), what is happening exactly? ? How can an instance of D with name 'd' be initialized with an instance of D also with name 'd'? Chicken or the egg?
Thanks in advance