"..." is not a type name

So, I'm getting back in the swing of coding things after a few jumps and starts, and have been following along on an OCW course on C++. The current problem I am working on has you develop two classes - a Point and a PointArray - in the same header/cpp file. However, in my PointArray header I get the message"Point is not a type name" from Visual Studio. The two class definitions are

1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Point
{
private:
	int x;
	int y;

public:
	Point(int nx = 0, int ny = 0){ x = nx; y = ny; };
	int getX() const{ return x; }
	int getY() const{ return y; }
	void setX(const int newX){ x = newX; }
	void setY(const int newY){ y = newY; }

};  


and

1
2
3
4
5
6
7
class PointArray
{
private:
	Point *parray; //"Point is not a type name
	int length;

};


I thought it was probably just me being silly, and after tinkering with it for half an hour, decided to try just dropping the answer that the course has online into my program. However, It gives me the same issue. Any help would be greatly appreciated.
Did you forward declare or include the point header in the pointArray file?

Btw in this case I would personally do something like

1
2
3
4
5
6
7
8
struct Point
{
    int x;
    int y;
};


std::vector<Point> points;


or even
std::vector<std::pair<int, int> > points;
Last edited on
Sorry, I got busy with work last night and couldn't come back on.

Both of these class declarations are in the same header file. Poor practice, I'm sure, but i was just following along with the course guideline.

std::vector is a c++11 thing, yes? The course I am following along with is c++ 03 based, so I haven't used any c++ 11-isms, even when they would be more efficient/elegant.
std::vector is like 1995. Even std::pair is as old as first standard.
Oh. Well, my mistake then.
Well is the point class or PointArray class declared first? If you could show the entire file it would help.
Topic archived. No new replies allowed.