PDA

View Full Version : extern class



zorro68
5th October 2007, 21:42
Hi. I want to define a global class variable. I have defined in my main.cpp this:
IDIOMA lang; //IDIOMA is the class name.
and then in other .cpp I have write:
extern IDIOMA lang;
I have no compiler error and no linker error, but when i used some member of lang is empty (lang.number for example).

What happend? How can I defined a global class variable that i can used in all modules of my programm?

Thanks

jacek
5th October 2007, 21:55
It looks like you do everything right. Did you remember to initialize lang? Do you have any other global variables or maybe static ones?

marcel
5th October 2007, 22:08
Or implement a singleton class.