Hi. Im still getting those problems using Classes in one file and my main subroutine in another. Ive tried copying the class definition into my main file, putting it in a seperate file and including it in both the class and main program files and im still getting compile errors.
Lewis
That's odd. I have 4 or 5 classes in one header file that every file includes and it works fine. Maybe you could post the errors you're getting and the class definitions and I can help.
Ok main source file:
class myWindow : window {
declare OnCreate();
declare OnClose();
}
global sub main() {
myWindow Win;
Win.Create(0,0,640,480,AWS_CAPTION|AWS_VISIBLE|AWS_BORDER|AWS_SYSMENU|AWS_AUTODRAW,0,"Test GUI",null);
do {
wait();
} until Win.m_hwnd = 0;
return;
}
And The Class File
class myWindow : window {
declare OnCreate();
declare OnClose();
}
myWindow :: OnClose() {
Destroy();
return true;
}
myWindow :: OnCreate() {
CenterWindow();
return true;
}
And the errors...
Compiling...
Main
C:\Documents and Settings\Administrator\My Documents\Projects\GUI\Main.src:23: error: symbol `myWindow@OnClose' undefined
C:\Documents and Settings\Administrator\My Documents\Projects\GUI\Main.src:23: error: symbol `myWindow@OnCreate' undefined
Error(s) in assembling "C:\Documents and Settings\Administrator\My Documents\Projects\GUI\Main.asm"
myWindow
Any ideas?
Lewis
Give me a minute to look into it.
Paul.
It's a small logic bug...will fix shortly.
Instead of duplicating your class definition you shour really use an include file. Not that that would make a difference in this case.
Paul.
Oh, I see. My classes aren't using virtual functions. Not much I can do since it's a compiler bug :)
Yes they are. Just use the virtual keyword until I fix the bug.
class myWindow : window {
declare virtual OnCreate();
declare virtual OnClose();
}
The compiler was correctly marking the function as virtual, since the base class function was declared as such. But it was neglecting to check to see if it was an external function.
C++ forces the virtual keyword on derived classes, I am attempting to avoid it ;)
Paul.
The window ones are, but I was referring to classes that I use for stacks, dictionaries, etc.
Sorry,
Thought lewis posted ;)
Paul.