Create
a
struct
declaration with a single member function; then create a definition for that
member function. Create an object of your new data type, and call the member
function.
Write
and compile a piece of code that performs data member selection and a function
call using the
this
keyword (which refers to the address of the current object).
Show
an example of a structure declared within another structure (a
nested
structure
).
Also show how members of that structure are defined.
How
big is a structure? Write a piece of code that prints the size of various
structures. Create structures that have data members only and ones that have
data members and function members. Then create a structure that has no members
at all. Print out the sizes of all these. Explain the reason for the result of
the structure with no data members at all.
C++
automatically creates the equivalent of a
typedef
for enumerations and unions as well as
structs,
as you’ve seen in this chapter. Write a small program that demonstrates
this.