Hello guys and thanks to all of you in advance for the help.
So for the question:
I have 2 simple classes
class Vector2D{
float X,Y;
}
class Point2D{
float X,Y;
}
as simple as it gets.
Now I want to be able to perform basic math on them like
Vector2D vec;
Position2D EntityPosition1;
Position2D EntityPosition2;
vec = EntityPosition1 - EntityPosition2;
Now I already have an operator overload for the - but when I try to do it says that there is no possible conversion from Point2D to Vector2D, fare nuff.
Simple googling pointed me to the conversion functions but while I was browsing I was left with the impression that conversion functions are actually a bad thing, is that true or did I just go too shallow on the googling :o ?
Also about the syntax itself.
So I added this peace of code into my Vector2D class header
operator Point2D();
so far so good but when I go into the Vector2D.cpp file and simply write
operator Point2D(){
}
without adding anything else I immidatly get an error message saying "conversion function must be a nonstatic member function", that doesnt really make sence considering its a member function and its not static ( atleast thats my understanding of the syntax while looking at the examples on google but I guess I am clearly wrong )
I dont understand the syntax of how this things works and quite frankly documentiation on google doesnt make it easyer as well, I am not sure how the syntax even works or if I should be using conversion functions to begin with.
Again thanks in advance for the help guys and sorry for the long post on this simple mather, any help appriciated <3
P.S: I've been loving the Game developing article project so much its really a great way to learn.