Header files interference

Hello.

I'm doing a project for an mp3 player. I have to clases GUI and Core. Core hava a constructor Core(GUI * gui). Both classes have a header file with something like:

//Core.h

#ifndef CORECLASS

#define CORECLASS

...//class delcaration

//end if

The problem is that I can't compile any of them. I have this message with G++ ans sunCC:

GUI.h:40: error: ISO C++ forbids declaration of 慍ore?with no type

GUI.h:40: error: expected ?before ?token

GUI.cpp have #include "Core.h" and Core.cpp have #include "GUI.h". If I remove this directives in any of the files, the output of the compiler is the same.

I need help

[687 byte] By [RaulHuertasa] at [2007-11-27 4:33:40]
# 1
Could you show line 40 from GUI.h?
Atanasyana at 2007-7-12 9:43:32 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2

This is a part of GUI.h

[code]class GUI : public QMainWindow

{

Q_OBJECT

private:

Core *core;//Line 40

...

}

[/code]

and this is the constrictor of Core:

[code]

class Core {

public:

PlayList *lista;

GUI* gui;

Player *player;

public:

Core(GUI* tgui);

~Core();

void play(int index );

[/code]

RaulHuertasa at 2007-7-12 9:43:32 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3
Try to write:class Core;class GUI : public QMainWindow{Class GUI use Core and class Core use GUI. So you have to use forward declaration.
Atanasyana at 2007-7-12 9:43:32 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4
Thank you so much. I'm new to C++(from java) so this was very wear. Do you know any article I could read about this?Thanks!
RaulHuertasa at 2007-7-12 9:43:32 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 5
Get a good C++ textbook. The problem you ran into is basic in C and C++: a type must be declared before you can refer to it.You can find textbook recommendations at the web site of the Association of C and C++ Users: http://www.accu.org/
clamage45a at 2007-7-12 9:43:32 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 6

Hi

I'd add that if you want to kill two birds with one stone, then this book

http://www.phptr.com/bookstore/product.asp?isbn=0131879057&rl=1

covers C++ with Qt. I thought that it was a reasonably good beginner to intermediate text.

I have no connection with the authors/publisher.

Paul

Paul_Floyda at 2007-7-12 9:43:32 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 7
Thank you so much guys.
RaulHuertasa at 2007-7-12 9:43:32 > top of Java-index,Development Tools,Solaris and Linux Development Tools...