![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |
| |||
| Yes, that will work since operator overloading allows the same flexibility as overloading a function. (confined within the usual 'rules' of those operators of course) You can also change an operator's behaviour dependent on the type of the either operand, externally from a class. Code: class foo
{
public:
friend float operator+ (float, const foo&);
friend float operator+ (int, const foo&);
};
float operator+ (float, const foo&);
float operator+ (int, const foo&); Last edited by Bench : 05-13-2008 at 06:45 AM. |
| The Following User Says Thank You to Bench For This Useful Post: | ||
MrPickle (05-13-2008) | ||
![]() |
| Thread Tools | |
| Display Modes | |
| |