Mid-Term Exam Questions and Answers


>1. the author states in chapt. 2 that >the IntType defined in chapt. 3 is >better than the one in Chapt. 2. why? I don't have the book with me, so can't say precisely. My *guess* is that the better one provides a more complete interface for all the required operators and/or is capable of representing arbitrarily large integers. The standard int and long built-in types are restricted to representing integers in 32 or 64 bits. For cryptography, this is in adequate, since you need to be able to represent large prime numbers (say up to 1024 bits of precision).

 >2. What is the difference between 
 >template <class IntType>
 >class Rational
 >{ ...
 >};
 >and 
 >template <class Etype>
 >class Rational
 >{...};
 >and 
 >template <class T>
 >class Rational
 >{...};
 >isn't T, Etype, etc. just a kind of placeholder
 >for your object type?

Correct. A template parameter can be any valid symbol (other than a C/C++ keyword). 
I use 'T' mostly, the author of the book uses Etype and T. You can use any letter
that suites you, or name that hints at the meaning of the template parameter.