Write a simple function template for predicate function isEqualTo that compares its two arguments of the same type with the equality operator (==) and returns true if they are equal and false otherwise. Use this function template in a program that calls isEqualTo only with a variety of built-in types. Now write a separate version of the program that calls isEqualTo with a user-defined class type,

but does not overload the equality operator. What happens when you attempt to run this program? Now overload the equality operator (with the operator function) operator==. Now what happens when you attempt to run this program?

What will be an ideal response?


If the user-defined class does not overload the equality operator (i.e., comment out
lines 30–33 in the solution below), the compiler would report an error indicating that the class does not define this operator or a conversion to a type acceptable to the pre-defined operator. Once the class overloads the equality operator, the program should run fine.

Computer Science & Information Technology

You might also like to view...

When method printf requires multiple arguments, the arguments are separated with ________.

a. colons (:). b. semicolons (;). c. commas (,). d. periods (.).

Computer Science & Information Technology

All of the following are important when first analyzing a database EXCEPT:

A) name of the table. B) fields making primary key(s) of the table. C) index of the table. D) definition of each field in the table.

Computer Science & Information Technology

Böhm and Jacopini used a simple system of flowcharting with two symbols: ovals to show each step in an algorithm, and diamond-shaped boxes to show what they called a logical predicative.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Which two components are more likely to be included in an HTPC design? (Select two.)

A) Dual monitors B) HDMI port C) RAID D) Video capture card E) Digital audio F) NAS

Computer Science & Information Technology