![]() |
![]() |
![]() |
![]() |
![]() |
|
Nevertheless, the member functions of the header class absolutely
need access to the private member variables and to the private constructor
of the link class. Accordingly, C++ provides a mechanism whereby
the link class can grant complete access privileges to the member
functions of the header class. To use this privilege-granting
mechanism, you add a friend declaration to the definition of the
link class:
class link {
friend class header;
private:
link *next_link_pointer;
railroad_car *element_pointer;
link (railroad_car *e, link *l) {
element_pointer = e;
next_link_pointer = l;
}
};