Friend Class - Declaration

Declaration

Classes are declared as friends within the definition of the class to whom access is to be given; this prevents a class from giving itself access to another's protected members, which enforces encapsulation. The friend class has the same level of access irrespective of whether the friend declaration appears in either the public, protected or private sections of the class definition. Friend status is granted by using the friend keyword:

friend class ClassName;

Read more about this topic:  Friend Class

Famous quotes containing the word declaration:

    I foresee the time when the painter will paint that scene, no longer going to Rome for a subject; the poet will sing it; the historian record it; and, with the Landing of the Pilgrims and the Declaration of Independence, it will be the ornament of some future national gallery, when at least the present form of slavery shall be no more here. We shall then be at liberty to weep for Captain Brown. Then, and not till then, we will take our revenge.
    Henry David Thoreau (1817–1862)

    I believe the declaration that “all men are created equal” is the great fundamental principle upon which our free institutions rest.
    Abraham Lincoln (1809–1865)

    The Declaration [of Independence] was not a protest against government, but against the excess of government. It prescribed the proper role of government, to secure the rights of individuals and to effect their safety and happiness. In modern society, no individual can do this alone. So government is not a necessary evil but a necessary good.
    Gerald R. Ford (b. 1913)