Hi,
I tried to initialize a new class within WM_CREATE:
CClass MyNewClass ();
Then I got the error below.
Can sombody please explain that to me? I don't understand. Why isn't it possible to create a new class in switch .....
case WM_CREATE:
CClass MyNewClass ();
break;
.........
Compiler: Default compiler
Building Makefile: "E:\Earth Lost\Software\Makefile.win"
Fhrt make... aus
make.exe -f "E:\Earth Lost\Software\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Programme/Dev-Cpp/include/c++" -I"C:/Programme/Dev-Cpp/include"
main.cpp: In function `LRESULT WindowProcedure(HWND__*, unsigned int, unsigned
int, long int)':
main.cpp:72: jump to case label
main.cpp:70: crosses initialization of `CRebar MyRebar'
main.cpp:93: jump to case label
main.cpp:70: crosses initialization of `CRebar MyRebar'
main.cpp:96: jump to case label
main.cpp:70: crosses initialization of `CRebar MyRebar'
Internal compiler error: Error reporting routines re-entered.
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
make.exe: *** [main.o] Error 1
Ausfhrung beendet
Thank you very much
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
you don't want to define your class in your message loop, try defining the class elswhere and then create an instance of the class in the loop, I think that should work.
// somewhere at beginning of program
class MyNewClass(){yadda.. yadda..};
// in switch statement
case WM_CREATE:
MyNewClass MyObject;
break;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hmm.. looking again, I think I read the original post wrong.. I thought you were defining the class under WM_CREATE (I saw CClass as class.. not awake yet..)
So.. I think what I would do is either create your class object globaly, or statically in the window function.
I thought, that the question was, why cannot I declare a variable in switch statement. For example: switch (something) { case 1: int a = 3; } is OK, but the compiler won`t compile it. Why?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I tried to initialize a new class within WM_CREATE:
CClass MyNewClass ();
Then I got the error below.
Can sombody please explain that to me? I don't understand. Why isn't it possible to create a new class in switch .....
case WM_CREATE:
CClass MyNewClass ();
break;
.........
Compiler: Default compiler
Building Makefile: "E:\Earth Lost\Software\Makefile.win"
Fhrt make... aus
make.exe -f "E:\Earth Lost\Software\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Programme/Dev-Cpp/include/c++" -I"C:/Programme/Dev-Cpp/include"
main.cpp: In function `LRESULT WindowProcedure(HWND__*, unsigned int, unsigned
int, long int)':
main.cpp:72: jump to case label
main.cpp:70: crosses initialization of `CRebar MyRebar'
main.cpp:93: jump to case label
main.cpp:70: crosses initialization of `CRebar MyRebar'
main.cpp:96: jump to case label
main.cpp:70: crosses initialization of `CRebar MyRebar'
Internal compiler error: Error reporting routines re-entered.
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
make.exe: *** [main.o] Error 1
Ausfhrung beendet
Thank you very much
you don't want to define your class in your message loop, try defining the class elswhere and then create an instance of the class in the loop, I think that should work.
// somewhere at beginning of program
class MyNewClass(){yadda.. yadda..};
// in switch statement
case WM_CREATE:
MyNewClass MyObject;
break;
i didnt take the time to read it but couldnt u do this?
#includes...
int main() {
CClass pointer;
int var_tobe_evaluated=10;
int var;
var=pointer::Function_from_class(var_tobe_evaluated);
cout<<"var = "<<var<<endl;
system("pause");
return 0;
}
um... not the problem guys... any variable used in the wrong way inside of a switch case will see that error...
either use pointers... or use a global instance of the class.. something like this... just typed it in so there maybe be a slight parse error...
Zero Valintine
LRESULT CALLBACK msgproc(HWND h, UINT a, WPARAM b, LPARAM c){
static CClass * MyNewClass;
switch(a){
case WM_CREATE:
MyNewClass = new CClass();
break;
hmm.. looking again, I think I read the original post wrong.. I thought you were defining the class under WM_CREATE (I saw CClass as class.. not awake yet..)
So.. I think what I would do is either create your class object globaly, or statically in the window function.
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static CClass MyClass;
switch (message)
{
case WM_CREATE:
etc...
}
}
I thought, that the question was, why cannot I declare a variable in switch statement. For example: switch (something) { case 1: int a = 3; } is OK, but the compiler won`t compile it. Why?
Yes i got it.
Thanks everybody for the help.
Alex
I just read the post from oxygenium.
The question is already in the air.
Alex