Originally Posted by
Programmer_P
And can't you only define (and/or declare) objects inside int main (which would exist in the main source code file)?
No, you can define them in other functions as well (including member functions), or if they are to have static storage duration, outside of functions too.
Originally Posted by
Programmer_P
The whole point I'm getting at here is I want to define my member variables inside the same file as the class, and so in this particular case, the same file which will store "edit_menu_options_class" which will be separate from main.cpp.
I think that instead of "define" you want to "initialise" in the sense of providing an initial value other than garbage.
Originally Posted by
Programmer_P
Ok, so would something like this work?
Yes (other than the global main function), but why is the member variable protected instead of private? You also do not need to explicitly define the destructor. You should use the initialisation list in the constructor, e.g.,
Code:
edit_menu_options_class::edit_menu_options_class() : undo("Undo") {}
As for the global main function... it depends on what you are trying to do. Obviously attempting to print a variable that has not even been declared will not work.