Reputation: 724
I'm getting this error when I'm trying to build my project:
Angle.cpp:466: error: ambiguous overload for 'operator<<' in '(+out)-
>std::basic_ostream<_Elem, _Traits>::operator<< [with _Elem = char,
_Traits = std::char_traits<char>](((const Angle*)this)->Angle::getDegrees())
<< "\37777777660"'
I've done some research on it and it looks like I have a wrong method header, but I'm new to cpp and don't know how to fix this error.
Here's the .h:
#include "OutputOps.h"
// End user added include file section
#include <vxWorks.h>
#include <ostream>
class Angle {
public:
// Default constructor/destructor
~Angle();
// User-defined methods
//
// Default Constructor sets Angle to 0.
Angle();
...
// Returns the value of this Angle in degrees.
double getDegrees() const;
....
// Prints the angle to the output stream as "x°" in degrees
void output(std::ostream& out) const;
...
private:
...
double radians;
static const double DEGREES_PER_RADIAN /* = 180.0 / PI */;
};
#endif // ANGLE_H
And here's the method:
#include "MathUtility.h"
#include <cmath>
// End user added include file section
#ifndef Angle_H
#include "Angle.h"
#endif
//
// Prints the angle to the output stream as "x°" in degrees
void Angle::output(std::ostream& out) const
{
out << getDegrees() << "°";
}
//
// Returns the value of this Angle in degrees.
double Angle::getDegrees() const
{
return radians * DEGREES_PER_RADIAN;
}
Upvotes: 2
Views: 1612
Reputation: 258668
My guess is that the problem lies with the degree sign, which isn't an ascii character.
Try instead:
wcout << getDegrees() << L"\u00B0";
Upvotes: 2