我主要的相关代码如下:
using namespace std;
typedef vector<CBox> MineVector;(每个雷区中的小格都是CBox类型)
MineVector m_Mines;                     //所有的雷在开局是调用了随机排序函数:
random_shuffle(m_Mines.begin(),m_Mines.end(),MyRand);int CMineSweepingDlg::MyRand(int n)
{
srand((unsigned int)time(0));
return rand()%n;
}
编译时总是出问题:
 error C2664: 'void __cdecl std::random_shuffle(class CBox *,class CBox *,int (__thiscall *)(int))' : cannot convert parameter 3 from 'int (int)' to 'int (__thiscall *)(int)'我觉得是自定义的函数有问题,但实在是不知道怎么改

解决方案 »

  1.   

    MyRand(int n)
    这个形参类型要和向量m_Mines里的元素类型相同
      

  2.   

    我的问题通过其它途径解决了,希望各位帮忙想想另一个问题:
        我以CStatic为基类创建了上面的CBox类,并设了位图作为雷区中的每个小格,但是有时就是刷不出来。
        开始创建时都能正常显示,但只要点开一个格,再开局就会有的小格显示不出来(每次开局都会用洗牌来打乱每个小格的排列顺序),但是要是不重新排序,而是按照原来的顺序格局来刷新显示就没问题。
      

  3.   

    CMineSweepingDlg::MyRand(CBox ) 这里的类型要用CBox 
      

  4.   

    为了方便大家,我还是把我用的方法写出来吧:
             srand((unsigned)time(0));
    random_shuffle(m_Mines.begin(),m_Mines.end());
    其实不用写第三个参数,直接设种子就成了。