I have a class Vector that needs to have a function that returns type Point, and a class Point that needs to have a function that returns type Vector.
I was informed that I needed to use forward references, which I thought I had implemented as follows. I am still getting this error: use of undefined type 'Vector'
Here are my files:
Point.h
class Vector;
class Point
{
public:
Vector GetVector()
{
Vector A;
return A;
}
};
Vector.h
class Point;
class Vector
{
public:
Point GetPoint()
{
Point A;
return A;
}
};
Program.cpp
#include <iostream>
#include "Point.h"
#include "Vector.h"
using namespace std;
void main()
{
Point P;
Vector V;
}
Surely this is a very easy problem and I am just doing something silly. Please let me know.
Thanks!
Dave