From 15dcba20aa4567a8e8cdaa1750383283a28c9898 Mon Sep 17 00:00:00 2001 From: "Jason L. Wright" Date: Mon, 23 Oct 2023 07:57:14 -0600 Subject: [PATCH] struct assignment no longer needs case (C++11) --- book/cha8.tex | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/book/cha8.tex b/book/cha8.tex index 30ccf35..6c0f5dc 100644 --- a/book/cha8.tex +++ b/book/cha8.tex @@ -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: