I can't believe I didn't remove the defaults earlier. I had used them for my constructor so that you could just create an empty menu and add the different pieces to it as you wish and must have just carried them on through there. A simple removal of = "" from a few spots and the removal of the Display call had fixed my issue.
One thing I don't understand is this:
MainMenu.AddOption("MultiPlayer", std::bind(&Menu::Play, std::ref(MultiMenu), 1));
I don't understand why I
need the one. I assume it was supposed to be for the ...Play(1) I asked about earlier, but I have Play to have a default of 1, why is this needed?
In regards to polymorphism, I do understand it in regards to animals, I've seen it a lot with dogs, trees, plants, etc. And as you said, it's not so obvious here. I will have to look into what kind of Options I will have and create something based off of that. Is there anyway that I can make those option classes nonaccessible to others using my code, but still allow it to be used by my menu class only? I'm not sure if that's easy to understand, but essentially just make it a child of the menu class and let no one else touch it?
And here:
dog->Speak();
I don't use pointers as much (I believe that's what they're called) but can I use the dot operator? What's the difference? If no, is it because we're pointing to the dog that was passed and telling that specific dog to speak?
Would it do the same thing as doing:
1 2
|
myPoodle.Speak();
myLab.Speak();
|
back in main?
As for overloading, when I make another AddOption(string, ...) function, AddOption will be overloaded because the compiler will have to sort out which AddOption I want, correct?
Also here:
void AddOption (std::string option, std::function<int ()> func) {
And here:
std::vector<std::function <int ()>> vMenuFunctions;
Since I have no idea what kind of functions someone else may be calling, or me for that matter, is a template a good idea? Can one be implemented in this case? I've seen a good bit of examples, but I don't recall ever seeing one being used with the function type before.
I feel a big long rewrite of my entire menu class coming along, and I have plenty of paper and pencils for all of the changes and new ideas to be brainstormed.
I really owe you some beers, a nice steak dinner, something to make up for the head pounding you've saved me from already.
(I think I might steal some of the beers just to get me through all of this) -.-