dice.h

来自「C++&datastructure书籍源码,以前外教提供现在与大家共享」· C头文件 代码 · 共 32 行

H
32
字号
#ifndef _DICE_H#define _DICE_H//  class for simulating a die (object "rolled" to generate//                              a random number)////  Dice(int sides) -- constructor, sides specifies number of "sides"//               for the die, e.g., 2 is a coin, 6 is a 'regular' die////  int Roll() -- returns the random "roll" of the die, a uniformly//                distributed random number between 1 and # sides//    //  int NumSides() -- access function, returns # of sides////  int NumRolls() -- access function, returns # of times Roll called//                    for an instance of the classclass Dice{  public:    Dice(int sides);           // constructor    int Roll();                // return the random roll    int NumSides() const;      // how many sides this die has    int NumRolls() const;      // # times this die rolled      private:    int myRollCount;           // # times die rolled    int mySides;               // # sides on die};#endif    /* _DICE_H not defined */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?