Reputation: 29
I have a class
class Cartesian
{
float x,y,z;
};
and another class
class Spherical
{
float rho, phi, r;
};
How would I convert between them?
I have tried adding Spherical Cartesian::toSpherical
and Cartesian Spherical::toCartesian
inside of the class declarations but no matter the order I put them in, the first one complains that the other one is undefined. I have tagged VS and Ubuntu because I want it to work for both.
Upvotes: 0
Views: 79
Reputation: 1843
Do the forward declaration.
class Spherical;
class Cartesian
{
float x,y,z;
Spherical toSpherical();
};
class Spherical
{
float rho, phi, r;
Cartesian toCartesian();
};
Upvotes: 1