I'm trying to learn Visual c++ 2005, I'm running into a problem returning objects in a function. I wrote a class called Point that stores x, y coordinates
Code:
ref class MyPoint
{
private:
int x;
int y;
public:
int getX();
int getY();
void setX(int newVal);
void setY(int newVal);
};
And I have another class that stores a group of points:
Code:
ref class GroupOfPoints
{
private:
MyPoint a;
MyPoint b;
public:
MyPoint getPointA() { return a; }
MyPoint getPointB() { return b; }
};
But it's giving me a compiler error for my 'get' functions like, "cannot convert MyPoint to MyPoint" which I don't really understand since they're the same thing aren't they?
I've looked at the msdn help and all they provide is:
Code:
typedef struct
{
char name[20];
int id;
long class;
} STUDENT;
/* Return type is STUDENT: */
STUDENT sortstu( STUDENT a, STUDENT b )
{
return ( (a.id < b.id) ? a : b );
}
Which is all fine and good and stuff but I'm trying to use their managed classes, not structures... Then the help goes on to say that I should return a reference which I kinda understand how to do in the old C++ format using "*'s" and "&'s" for native heap stuff. But the new C++ 2005 uses "^" for the managed heap and I can't find any examples on how to return a reference using the new syntax.