Operator Overload

Operator Overload

Page 1 of 1

4 Replies - 1933 Views - Last Post: 28 April 2005 - 08:25 PM Rate Topic: -----

#1 paswordad  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 18-April 05

Operator Overload

Post icon  Posted 28 April 2005 - 02:16 PM

Can anyone help me with Operator Overload. I have know Idea how to use this, Any thing at this point will help. :unsure:
Is This A Good Question/Topic? 0
  • +

Replies To: Operator Overload

#2 Videege  Icon User is offline

  • rÍvant.toujours
  • member icon

Reputation: 6
  • View blog
  • Posts: 1,413
  • Joined: 25-March 03

Re: Operator Overload

Posted 28 April 2005 - 03:05 PM

I believe you can define operators in this manner (particularly useful for defining specific ways structures/classes should work with each other).


class point
{
float x, y, z;

point operator + (point a, point b) //or is it point::operator? I can never remember
{
point temp;
temp.x = a.x + b.x;
temp.y = a.y + b.y;
temp.z = a.z + b.z;
return temp;
}
}


Was This Post Helpful? 0
  • +
  • -

#3 paswordad  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 18-April 05

Re: Operator Overload

Post icon  Posted 28 April 2005 - 03:45 PM

Thank you. That helps out a lot...
Was This Post Helpful? 0
  • +
  • -

#4 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Operator Overload

Posted 28 April 2005 - 06:45 PM

This example is similar to Videege's...
Was This Post Helpful? 0
  • +
  • -

#5 Videege  Icon User is offline

  • rÍvant.toujours
  • member icon

Reputation: 6
  • View blog
  • Posts: 1,413
  • Joined: 25-March 03

Re: Operator Overload

Posted 28 April 2005 - 08:25 PM

No problem. I'm glad I remembered how to do it, lol :).

As always, Amadeus has obtained a better reference on the subject ;). So check that out.

This post has been edited by Videege: 28 April 2005 - 08:25 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1