Since x_str,y_str are local, I am not getting the correct output in this function. (Illegal chars are printed in the place of x_str and y_str)
I dont want to add 2 more member variables x_str,y_str to my class.
Hence what could be the replacement of this function to get correct output.
string Pos::getPosReport(){
string x_str;
x_str = x;
string y_str;
y_str = y;
return string("(" + x_str + "," + y_str + ")" );
}
EDIT:
class Pos {
int x;
int y;
public:
Pos();
Pos(Pos const&);
Pos(int,int);
Pos& operator=(Pos const&);
bool operator==(Pos const&);
bool operator!=(Pos const&);
void setPos(Pos const&);
void setPos(int,int);
void setx(int);
void sety(int);
int getx() const ;
int gety() const ;
string getPosReport();
virtual ~Pos();
};
(this is the whole function body).