When I try to change a Static int value it gets an error saying it's undefined from Dev-C++?
static int i;
when I try to use the class as a varible like this
it get an error like this twice
(linker error) undefined reference to i
- Anonymous1 decade agoFavorite Answer
Yep, you must initialize it. If you don't initialize it, it first complains because it doesn't know how to increment the variable. Then it will complain when it hits the decrement operator. Since this is a class and those statements would be called as the constructor and destructor are called, this will be called as well. You can create a static without initialization in most cases, but leaving it blank here makes it undefined behavior if the compiler trys to increment or decrement it.Source(s): The twisted mind of me.
- Anonymous4 years ago
see first you may desire to appreciate what's a linker and what's a linker errors. After code compilation, that code is suited with each and all the library purposes existent on your turboC itemizing...Now, that's the activity of the linker to ascertain the physique of the needs u have used like printf, scanf and so on...Now you have used one functionality reported as "symbol_circle" which you have declared and reported as from the main valuable functionality yet you havent declared the physique of it...during linking time, the linker sees that the functionality is declared as although if it has have been given no corresponding code to execute...write a physique of that functionality.....then u will discover no linker errors will ensue..
- Anonymous1 decade ago
doesnt i have to have a first initial value?