October 2011
Beginner to intermediate
1200 pages
35h 33m
English
References work wonderfully with structures and classes, C++’s user-defined types. Indeed, references were introduced primarily for use with these types, not for use with the basic built-in types.
The method for using a reference to a structure as a function parameter is the same as the method for using a reference to a basic variable: You just use the & reference operator when declaring a structure parameter. For example, suppose we have the following definition of a structure:
struct free_throws{ std::string name; int made; int attempts; float percent;};
Then a function using a reference to this type could be prototyped as follows:
void set_pc(free_throws & ft); // use a reference to a structure ...
Read now
Unlock full access