不幸的是我还接到了在这里与我的模板代码的问题:C++问题的std ::对,前置声明
C++ fancy template code problem
上的文件“实用工具”中的第49行:
error C2440: 'Initializing': cannot convert from 'const int' to 'IntersectionData *'
error C2439: 'std::pair<_Ty1,_Ty2>::second': member could not be initialized
我怎么能找出问题出在哪里?我用“IntersectionData *”一对的唯一的地方是在这里:
#include "MRMaterialMatth.h"
#include "IntersectionData.h"
using namespace std;
struct IShaderMatth {
virtual ~IShaderMatth() {}
vector<pair<MaterialMatth,IntersectionData*> > traceCols;
};
,并没有任何其他的编译器错误
我怎么能追踪到这一点?
//编辑:实用程序不是我的代码。它必须是由STD ..线49的代码如下所示:
template<class _Other1,
class _Other2>
pair(const pair<_Other1, _Other2>& _Right)
: first(_Right.first), second(_Right.second)
{ // construct from compatible pair
}
线49是注释的行
EDIT2: 在那里我改一下tracecols的内容的时候,唯一的地方是这样的:
IntersectionData* iDataOut = NULL;
if(newIData_out!=NULL)
{
iDataOut = new IntersectionData(*iData);
}
traceCols->push_back(make_pair(MaterialMatth(),iDataOut));
和
if(traceCols){
traceCols->push_back(make_pair(MaterialMatth(), NULL));
}
和
if(traceCols)
{
(*traceCols)[traceCols->size()].second = new IntersectionData(*newIData);
}
是NULL的问题?它是一个指针,所以我应该被允许创建一个NULL对,没有?
什么是第49行? – 2009-12-16 01:55:32
实用程序的第49行是什么,以及您使用traceCols的其他位置? – Smashery 2009-12-16 01:56:04