C + + Primer Chinese 5th Edition Exercise 15.8 and exercise 15.9 answers

Source: Internet
Author: User

Exercise 15.8: Give definitions of static types and dynamic types.

A: Static type: Is the type of the variable declaration, or the type generated by the expression, and the type is known at compile time .

Dynamic type: Is the type of object in memory that is represented by a variable or expression and is not known until run time .

Exercise 15.9: Under what circumstances can the static type of an expression be different from a dynamic type? Please give three different examples of static types and dynamic types.

A: The first type: a function parameter is a reference to a base class (a static type), and when the function is called, the passed argument is the object of the derived class (the dynamic type).

The second type: a function parameter is a pointer to a base class (a static type), and when the function is called, the passed argument is a pointer to the derived class (the dynamic type).

The third type: a function parameter is a pointer to a base class (a static type), and when the function is called, the passed argument is a reference to the object of the derived class (the dynamic type).

C + + Primer Chinese 5th Edition Exercise 15.8 and exercise 15.9 answers

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.