12.05.2015 Views

type - David Vernon

type - David Vernon

type - David Vernon

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Classes and Objects<br />

Operator Overloading and Friend Functions<br />

• Example: vector addition<br />

–let u = (x u , y u ) and v = (x v , y v )<br />

– the vector sum s = (x s , y s )= u + v is given by<br />

x s = x u + x v<br />

y s = y u + y v<br />

• We will overload the addtion operator + for<br />

vectors so that we can write s = u + v;<br />

Copyright © 2007 <strong>David</strong> <strong>Vernon</strong> (www.vernon.eu)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!