I have the following class, which I friended with cout
and now I\'m trying to friend it with cin
but I get an error... Could anyone help me, or tel
There is not enough code to answer your question. But from error I would say you, that your int RAngle::operator<(RAngle)
is not defined as const method and you use it somewhere, where you have only const.
Also, it's not very good practive to make operator<
or other comparison operators return int, because this may lead to misunderstanding. Such operators should return bool
.
So, there sould be something like this bool RAngle::operator<(const RAngle& other) const { /*...*/ }
. This topic is covered here and here.
Update This code is completely strange. Why use pointers to int
? Why make some data private? Constructor RAngle(int i,int j,int k)
will not work as you suppose.