I've just been trying to share some data across files, and there's something I don't understand which I think might be behind some of the problems I'm having!
I have a shared header file, in which I declare, say, int foo = 5.
Then two other files which #include that header file, and both start with external declarations of foo - i.e. extern int foo.
They both report the correct value of foo, 5, but the value of &foo in each case is different. Is that expected, and if so why?
When a variable is declared inside a header file (NOT externed), every .cpp file that includes that header file,
directly or indirectly, gets its own copy of that variable. You are seeing multiple addresses because you have
multiple variables with the same name.
To answer my own question: yes. I made a couple of stupid assumptions about the way I set up this project. Sorry if anyone's wasted any time on my last post, but thanks again for answers to the first one - they did help!