Datasim Financial Forums Forum Index


 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
6. Overloading and Operators

 
Post new topic   Reply to topic    Datasim Financial Forums Forum Index -> C++ Certification and Examinations: Intermediate Level
View previous topic :: View next topic  
Author 6. Overloading and Operators
Cuchulainn



Joined: 18 Dec 2006
Posts: 318
Location: Amsterdam, the Netherlands

PostPosted: Sun Feb 01, 2009 11:42 am    Post subject: Reply with quote

Can the following 'operators' be overloaded and where would they be used;

*
()
[]
%
&
.
->
^
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cuchulainn



Joined: 18 Dec 2006
Posts: 318
Location: Amsterdam, the Netherlands

PostPosted: Wed Jan 21, 2009 12:39 pm    Post subject: 6. Overloading and Operators Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Datasim Financial Forums Forum Index -> C++ Certification and Examinations: Intermediate Level All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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