Coercion and overloading

timer Asked: Oct 2nd, 2013
account_balance_wallet $5

Question Description

Consider an unknown language with integer and real types in which 1+2, 1.0+2, 1+2.0, and 1.0+2.0 are all legal expressions.

a. Explane how ths could be the result of coercion, using no overloading.

b. Explane how this could be the result of overloading, using no coercion.

c. Explane how this could result from a combination of overloading and coercion.

d. Explane how this could result from subtype polymorphism, with no overloading or coercion.

Tutor Answer

School: Duke University

#include <string>

class PlMessageHeader
std::string m_ThreadSender;
std::string m_ThreadReceiver;

//return true if the messages are equal, false otherwise
inline bool operator == (const PlMessageHeader &b) const
return ( (b.m_ThreadSender==m_ThreadSender) &&
(b.m_ThreadReceiver==m_ThreadReceiver) );

//return true if the message is for name
inline bool isFor (const std::string &name) const
return (m_ThreadReceiver==name);

//return true if the message is for name
inline bool isFor (const char *name) const
return (m_ThreadReceiver==name);// since name type is std::string, it becomes unsafe if name == NULL

flag Report DMCA

Tutor went the extra mile to help me with this essay. Citations were a bit shaky but I appreciated how well he handled APA styles and how ok he was to change them even though I didnt specify. Got a B+ which is believable and acceptable.

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors