> But since you were asked to do it a different way, here's a hint. Use the
> address of an object to identify it. If two objects have the same address
> they are the same object, if they have different addresses they are
> different objects. So write an expression that compares the address of the
> object you are assigning to with the address of the object you are assigning
> from.
>
> john
John Harrison's code eg. comes closer to anything else I thought we
may have had in mind. Is there anything improper with the definition
I have provided below? After previous testing, it seems to execute as
desired.
MutualFund& MutualFund:

perator = (const MutualFund& operand)
{
if(&(*this) == &operand)//client attempts to assign class object to
itself
{
cout << "Cannot assign the same object to itself." << endl;
return *this;
}
else
{
/*values are actually changed here rather than assigning the same
values of one class object's data members to another's in order to
demonstrate the false value of the if() condition, in other words, the
client did not attempt to assign a class object to itself in this
instance. Normally the values would not be changed and each of the
values of the data members pertaining to the original
class object would be assigned to the data members of the newly
instantiated
class object via the assignment statement*/
szFundName = new char[25];
strcpy(szFundName,"Coca-Cola");
iFundShares = 40;
dShareValue = 20;
dPortfolioValue = operand.dPortfolioValue;
return *this;
}//end if-else
}
Thanks in advance...
anthony