help with headder file containing class definition :)

Started by
19 comments, last by Rhaal 19 years ago
"class Line;"

I dont think it likes your ";" at the end of class decleration.
And i think you have forgotten the destructor for the class too.

Greetings
-Truth is out there-
Advertisement
That is wierd because I have a c++ book that told me I have to put ; at the end of every class declaration. I will try taking it off. the book also told me that destructors are optional. I will add one and see.

EDIT: no that didn't fix the problem
:(
These tears..leave scars...as they run down my face.
Quote:Original post by donjonson
That is wierd because I have a c++ book that told me I have to put ; at the end of every class declaration. I will try taking it off.

EDIT: no that didn't fix the problem
:(


well you wan't one at the end after the closing }
class A; //<--- no semicolon here please...{};//<-- but this one must be present
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
ahh damn I am blind.

EDIT:

Damn It still gives me the same error when i try to complie
These tears..leave scars...as they run down my face.
you have included <window.h> in the cpp file but you still use the HWND in the header file.

So one thing is to move <window.h> to the .h file.

I think its the last thing i can see.

Greetings
-Truth is out there-
Thanks for all your help But I still cant get it to compile.
If I move the definition of the draw function to the top of the lines.cpp file. it flags that saying that there is no member function called Line::draw(HWND), but it wont flag on the other member function definitions in lines.cpp. so for some reason it is excluding draw in the class definition.

These tears..leave scars...as they run down my face.
int T = 1; 


wtf! only static const integral data can be initilized like that.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
ok I figured out the problem.

for some reason devC++ was not saving my edits to the files. If I open up the project and make an edit and save the change will be there next time I open the project. but if i close the project and open the file individualy, the change will not have been made. hmm strange bug. In the actual file the draw declaration was commented out. I fixed it and it now compiles.
These tears..leave scars...as they run down my face.
You don't actually need to include windows.h in your class declaration. You just need to include the class header file AFTER windows.h. That way, the preprocessor treats it like its been declared after the stuff in windows.h.
Quote:Original post by Oberon_Command
You don't actually need to include windows.h in your class declaration. You just need to include the class header file AFTER windows.h. That way, the preprocessor treats it like its been declared after the stuff in windows.h.


And that's wrong for so many reason that I can't count them.
always, ALWAYS! make headers standalone if you can't pull in one header without also having to figure out what other arcane headers are needed you'll end up pulling your hair out later when you try to reuse stuff.

That doesn't imply including everything and it's mother forward declarations can many times suffice for headers but really that's one of the worst pieces of advice I heard on theese boards to date.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats

This topic is closed to new replies.

Advertisement