Как определить конструктор С++C++

Программы на C++. Форум разработчиков
Ответить
Гость
 Как определить конструктор С++

Сообщение Гость »


I have only been working with C++ for a year now and I am hoping to gain a better understanding of abstraction with my current project. I created a Black Jack card game from my book 'Beginning C++ Through Game Programming'. The game works, but I am working on a menu option that restarts the game, adds scores and allows you to view the scores via fstream.

This is what the menu section looks like inheriting from the base class Game:

class Menu { public: Menu(); ~Menu(); private: Game m_game; //saves scores to fstream from class Player m_player; //menu options void choice(); }; Menu::Menu() {} //no appropriate default constructor available for Game Menu::~Menu() {} void Menu::choice() { char respond; bool run = true; cout respond; switch (respond) { case 'R': m_game.play(); break; case 'A': //add new score to fstream case 'V': //view score txt file case 'Q': run = false; break; } } I am pretty confused about how to create the default constructor for this section, even with the examples from the book.

The constructor for the Game class looks like:

class Game { public: Game(const vector& names); ~Game(); //plays game void play(); private: Deck m_deck; House m_house; vector m_players; }; I'm hoping to get an explanation or example. Thank you for your help!


Источник: https://stackoverflow.com/questions/667 ... structor-c
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»