This function:
int dir_mag(double dir, double mag) :direction(dir), magnitude(dir)
{return 0; };
uses a list of initializers ( :direction(dir), magnitude(dir)) and allows only constructors. If you were planning on making this a constructor, your class should look like this:
class physics_vector
{
public:
double direction, magnitude;
physics_vector(double dir, double mag) :direction(dir),
magnitude(dir) {};
};
And it will compile. Note that you are not allowed to return a value from the constructor, and they do not have return types.
source
share