For my vertex class, I want to overload the operators. I am doing it the way I read to, but it will not work when I try to define the operators. For example, I have this in my class declaration:
vertex operator =(vertex x); // overload the assignment operator
vertex operator +(vertex x); // overload the addition operator
And in my class definition, I have this:
// overloaded assignment operator
vertex vertex::operator =(vertex x)
{
// return the assigned vertex
return(vertex(x.x, x.y, x.z));
}
// overloaded addition operator
vertex vertex::operator +(vertex &x)
{
// return the added vertex
return(vertex(x + x.x, y + x.y, z + x.z));
}
The class declaration goes smoothly with the compiler, but the definitions are what is screwing the program up. Can someone tell me what I am doing wrong here? If so, that would be wonderful.
Also, I was looking at d3dx.h, and I noticed that some of the overloaded operators had const appended to them. I think I will have to look this up in my reference, but what does const do to an operator?
Thanks for your patience.
When you go homeTell them of us, and say:For your tomorrow,We gave our today.