[Dev-C++] declaring two classes with pointers to each other?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Phil S. <fy...@qw...> - 2001-06-30 23:20:15
|
I want to create two classes that contain pointers to each other, but I
keep getting "Syntax error before *" I know a class can contain a
pointer to itself, but why not to others before it is fully defined?
The classes are declared in their own header files, which are
reciprocally included in the other... The function coding were in
separate .cpp files.. What am I forgetting?
-----author.h---- The stripped down versions..
#ifndef AUTHOR_H
#define AUTHOR_H
#include "book.h"
using namespace std;
class Author
{
public:
Book* works[20];
};
#endif
---book.h----
#ifndef BOOK_H
#define BOOK_H
#include "author.h"
using namespace std;
class Book
{
public:
Author* authorP;
};
#endif
--
Fy...@qw...
|