I found some code in the program I work with:
PWSTR myWchar = NULL;
WCHAR *p = myWchar = new WCHAR[4];
How would I read a line with two equal signs?
How is it computed?
A:
myWchar = new WCHAR[4];
WCHAR *p = myWchar
or B:
WCHAR *p = myWchar ;
myWchar = new WCHAR[4];
It's option A, exactly equivalent to (with unnecessary parens):
If
myWcharhad a customoperator=and/or the type ofphad a custom constructor or cast frommyWchar's type top's type, this could meanpandmyWcharend up slightly different from one another, but in this case,WCHAR*andPWSTRare fundamentally the same type, so they both end up assigned to the same thing, the result of thenew WCHAR[4].In this case, it's actually the result of assignment to
myWcharused as the initialization forp, but even if the structure was:so it was all assignment, no initialization, assignment is right-to-left associative, so it would occur in the same order (it just would use assignment rather than initialization semantics for the assignment to
p, which could matter for custom types).