View previous topic :: View next topic |
Author |
6. Overloading and Operators |
Cuchulainn
Joined: 18 Dec 2006
Posts: 318
Location: Amsterdam, the Netherlands
|
Posted: Sun Feb 01, 2009 11:42 am Post subject: |
|
|
Can the following 'operators' be overloaded and where would they be used;
*
()
[]
%
&
.
->
^ |
|
Back to top |
|
|
Cuchulainn
Joined: 18 Dec 2006
Posts: 318
Location: Amsterdam, the Netherlands
|
Posted: Wed Jan 21, 2009 12:39 pm Post subject: 6. Overloading and Operators |
|
|
We wish to add doubles to complex numbers and complex numbers to doubles:
Complex z1(-23.0, 5.3);
Complex z2(2.0, 3.0);
Complex z3 = z1 * z2;
Complex z4 = 2.0 * z4;
Explain how this code solves the problem:
friend Complex operator * (const Complex& c, double d);
friend Complex operator * (double d, const Complex& c);
Explain |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|