Question: Overview For this assignment, implement and use the methods for a class called Die. Overview For this assignment, implement and use the methods for a
Overview For this assignment, implement and use the methods for a class called Die. Die class The Die class is used to represent a 6-sided die. Data Members The class contains two data members An integer that holds the value of the side of the die that is up An integer symbolic constant that holds the maximum number of sides on the die. Use a value of 6. C++ 11 allows for symbolic constants to be initialized in the class definition. However, it's not something that is supported by all compilers because class definitions are treated as patterns for what the class should contain, and therefore, they don't take up any memory. To create a symbolic constant that will work for all compilers: 1. In the class definition, define the symbolic constant with the keyword "static" before the definition. So: static const int NUM SIDES 2. Before main, initialize the symbolic constant with its value. So: const int Die: NUM SIDES 6 Note the dropping of the keyword "static" and the inclusion of the "Die::" in front of the constant name. This lets the compiler know that the constant belongs to the Die class. Now, NUM_SIDES can be used in the class methods when needed. Constructor This class has one constructor, a default constructor (ie. one that takes no arguments). It should simply call the roll method that is described below to initialize the value of the side of the die that is up
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
