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.
Explanation & Answer
#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
}
};
Review
Review
24/7 Homework Help
Stuck on a homework question? Our verified tutors can answer all questions, from basic math to advanced rocket science!
Similar Content
Related Tags
Fools Crow
by James Welch
Big Little Lies
by Liane Moriarty
Harry Potter and the Sorcerers Stone
by J. K. Rowling
The Awakening
by Kate Chopin
The Secret Garden
by Frances Hodgson Burnett
The Unwinding of the Miracle
by Julie Yip-Williams
The Lord of the Flies
by William Golding
Big Magic
by Elizabeth Gilbert
One Flew Over the Cuckoos Nest
by Ken Kesey