
Originally Posted by
Shuchi Agrawal
i m declaring freebytes, usedbytes variables in globalvar.h
First of all you should avoid global variables as they can cause a lot of troubles. Secondly, you shouldn't define variables in header files, because every .cpp file that includes such header will have its own copy of those variables.
If you really want to use global variables you should do it this way:
// globalvar.h
...
extern int freebytes;
extern int usedbytes;
...
// globalvar.cpp
int freebytes = 0;
int usedbytes = 0;
// globalvar.h
...
extern int freebytes;
extern int usedbytes;
...
// globalvar.cpp
int freebytes = 0;
int usedbytes = 0;
To copy to clipboard, switch view to plain text mode
Bookmarks