Cryptography Reference
In-Depth Information
not by value, but by reference, that is, as pointers to the object. The same holds
for the return value of LINT objects. This use of & is unknown in C. On close
inspection, however, one recognizes that only certain of the member functions
return a pointer to a LINT object, while most of the others return their results by
value. The basic rule that determines which of these two methods is followed
is this: Functions that alter one or more of the arguments passed to them can
return this result as a reference, while other functions, those that do not alter
their arguments, return their results by value. As we proceed we shall see which
method goes with which of the LINT functions.
Classes in C++ are an extension of the complex data type struct in C, and
access to an element x of a class is accomplished syntactically in the same way as
access to an element of a structure, that is, by A.x , where A denotes an object and
x an element of the class.
One should note that in the parameter list of a member function an argument
is less completely named than in a like-named friend function, as the following
example illustrates:
friend LINT gcd (const LINT&, const LINT&);
versus
LINT LINT::gcd (const LINT&);
Since the function gcd() as a member function of the class LINT belongs to an
object A of type LINT ,acallto gcd() must be in the form A.gcd(b) without A
appearing in the parameter list of gcd() . In contrast, the friend function gcd()
belongs to no object and thus possesses no implicit argument.
We shall fill in the above sketch of our LINT class in the following chapters
and work out many of the details, so that eventually we shall have a complete
implementation of the LINT class. The reader who is also interested in a general
discussion of C++ is referred to the standard references [Deit], [ElSt], [Lipp], and
especially [Mey1] and [Mey2].
14.1 Not a Public Affair: The Representation of
Numbers in LINT
And if my ways are not as theirs
Let them mind their own affairs.
—A. E. Housman, Last Poems IX
 
Search WWH ::




Custom Search