{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CSE340_HW2_Solutions

CSE340_HW2_Solutions - Arizona State University Fulton...

Info icon This 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 type, f = g will not created problems. The two functions can be calls have the same call setup. The
Image of page 1

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern