문제

I've the following code that doesn't compile with vc++ 2013. Is it a compiler bug?

class Test
{
public:
    Test() :
        mTestBuff{ 1, 2, 3, 4 }
    {

    }

private:
    const vector< int > mTestBuff;
};

error C2661: 'std::vector<int,std::allocator<_Ty>>::vector' : no overloaded function takes 4 arguments

This compile fine with GCC 4.8 and MinGW. What can I done to remove the compile error?

도움이 되었습니까?

해결책

Try this:

Test() :
    mTestBuff({ 1, 2, 3, 4 })
{

}

Demo here.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top