1

TRandom课程添加到我的项目后,我开始收到这些错误:

Error   1   error C2039: 'result_type' : is not a member of 'TRandom'   e:\programy\microsoft visual studio 11.0\vc\include\xutility    3450
Error   2   error C2146: syntax error : missing ';' before identifier '_Ty1'    e:\programy\microsoft visual studio 11.0\vc\include\xutility    3450
Error   3   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   e:\programy\microsoft visual studio 11.0\vc\include\xutility    3450
Error   4   error C2065: '_Ty1' : undeclared identifier e:\programy\microsoft visual studio 11.0\vc\include\xutility    3452
Error   5   error C2070: ''unknown-type'': illegal sizeof operand   e:\programy\microsoft visual studio 11.0\vc\include\xutility    3452
Error   6   error C2065: '_Ty1' : undeclared identifier e:\programy\microsoft visual studio 11.0\vc\include\xutility    3453
Error   7   error C2923: 'std::_If' : '_Ty1' is not a valid template type argument for parameter '_Ty2' e:\programy\microsoft visual studio 11.0\vc\include\xutility    3453
Error   8   error C2955: 'std::_If' : use of class template requires template argument list e:\programy\microsoft visual studio 11.0\vc\include\xutility    3453
Error   9   error C2039: 'min' : is not a member of 'TRandom'   e:\programy\microsoft visual studio 11.0\vc\include\random  3600

现在我的项目中什至没有那个类(因为我删除了它以找出原因),但我仍然得到了那些。我认为这可能是某种错误,因为即使我不再有这个TRandom类,最后一个错误仍然提到它。我正在使用 MS Visual Studio 2012。

以防万一我还粘贴了我TRandom班级的代码:

cp文件:

#include "stdafx.h"
#include "TRandom.h"


using namespace std;
//using namespace tr1;

mt19937 TRandom::twister = mt19937();

TRandom::TRandom(void)
{
}


TRandom::~TRandom(void)
{
}


int TRandom::randomInt(int max, int min)
{
    //mt19937 twister;
    uniform_int_distribution<int> dist(max, min);
    return dist(twister);
}

double TRandom::randomDouble(double max, double min)
{
    //mt19937 twister;
    uniform_real_distribution<double> dist(max, min);
    return dist(twister); 
}

H 文件:

#if !defined(_TRANDOM_H)
#define _TRANDOM_H

#include <random>


class TRandom
{

private:
    static std::tr1::mt19937 twister;

public:
    TRandom(void);
    ~TRandom(void);

    static int randomInt(int max, int min);
    static double randomDouble(double max, double min);
};

#endif //_TRANDOM_H
4

0 回答 0