#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
class Shaizi
{
public:
int dianshu();
private:
int d;
};
int main()
{
Shaizi s1;
cout << "摇出的点数:" <<s1.dianshu()<<endl;
return 0;
}
int Shaizi::dianshu()
{
srand(time(0));
d=rand()%6+1;
return d;
}
成果展示: