When I try to run the programme, an error occurs and the compiler states that the "nation1" object in the "Nation.cpp" file is an undeclared identifier. This error doesn't occur if I combine the Nation class into the same file "Mainfile".
I've tried placing an #include "Mainfile.cpp" at the top of "Nation.cpp" but it was to no avail and there was an error still. To be honest I don't even know if that's allowed.
So my question is, how do I solve the error / let the object nation1 be recognised in the method "Nation.func()"?
This is in no way a homework question, I have just bought a book to learn C++ on my own an there's some areas which are not very well explained/elaborated so I decided to experiment with the codes on my own. Thank you.
So if I have many objects nation1, nation2, nation3, etc of the Nation class, then I want all these objects to only produce the output nation1.show*2
¿why is `nation1' so especial?
Regarding your code, you should realize that in the second snip `nation1' is global but in the first it's local to `main()'
Also, considering that you are not using the status of the object (but of a global one), there is no need to make it a method (just go with a function)