Question: (i) Suppose a C++ class is needed to represent a board game in a computer program. The class should be named Game and have one

(i) Suppose a C++ class is needed to represent a board game in a computer program. The class should be named Game and have one member variable for a 2D array of integers named game_board, with horizontal row size of BOARD_SIZE and vertical column size of BOARD_SIZE. Write a declaration for this class using the most suitable data types. Declare a default constructor and a copy constructor (with one parameter for a Game variable, passed by constant-reference). The constructors should be available outside the class but the variables should not be. (ii) Write the implementation for a function named getAt that returns the value in the array at a given position. Pass the row and column as parameters. Use the most suitable return type for the function. The function should be declared constant. (iii) Show how you would declare a variable in the main function of the Game type using the default constructor. Then show how to call the getAt function to get the value at row index of 2 and column index of 3. Save the value in a variable named pos.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!