Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struct assignment no longer needs cast (C++11) #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions book/cha8.tex
Original file line number Diff line number Diff line change
Expand Up @@ -143,26 +143,13 @@ \section{Operations on structures}
the structure one by one, in order. So in this case, {\tt x}
gets the first value and {\tt y} gets the second.

Unfortunately, this syntax can be used only in an initialization,
not in an assignment statement. So the following is illegal.
This syntax can also be used in assignment. So the following is legal.

\begin{verbatim}
Point blank;
blank = { 3.0, 4.0 }; // WRONG !!
blank = { 3.0, 4.0 };
\end{verbatim}
%
You might wonder why this perfectly reasonable statement should
be illegal; I'm not sure, but I think the problem is that the compiler
doesn't know what type the right hand side should be. If you
add a typecast:

\begin{verbatim}
Point blank;
blank = (Point){ 3.0, 4.0 };
\end{verbatim}
%
That works.

It is legal to assign one structure to
another. For example:

Expand Down