CSE340_HW2_Solutions

CSE340_HW2_Solutions - Arizona State University Fulton...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Arizona State University Fulton School of Engineering Computer Science and Engineering CSE 340 Fall 2009 Homework 2 Solution 6.4 (a) The two structures implicitly declare two unnamed types. x and y have the same unnamed type, since they are defined together, while z is not same with these two. Running this code on VS will generate the following compilation error: error C2440: '=' : cannot convert from '' to ''. As you can see, these two types are both anonymous. (b) 1. struct { int i; double j; } x, y, z; This is not a good way, because the type is still anonymous. 2. struct S { int i; double j; }x, y; struct S z; 3. typedef struct { int i; double j; } S; S x, y, z; 6.7 f and g have equivalent anonymous types. They have the same return type and the same types for their parameters. The parameter type and return value are used by the compiler to determine who calls to f and g are handled. For instance, the calling function would have to copy the parameters to the stack so that they can be used by f or g. Since the parameters they expect have the same
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/27/2011 for the course CSE 340 taught by Professor Farley,t during the Fall '08 term at ASU.

Page1 / 5

CSE340_HW2_Solutions - Arizona State University Fulton...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online