65,210
社区成员
发帖
与我相关
我的任务
分享
// 头文件中的声明
std::vector<C3dMaterial*> m_MaterialList;
bool SomeClass::LoadMtlData(CString filename)
{
std::vector<C3dMaterial*> ab;
m_TextureMapArray.clear();
m_MaterialList.clear();
CStdioFile mFile;
CFileException e;
if (!mFile.Open(filename, CFile::modeRead|CFile::typeText, &e))
{
TCHAR szError[1024];
e.GetErrorMessage(szError, 1024);
AfxMessageBox(szError);
return false;
}
mFile.SeekToBegin();
CString strTemp;
int tempIndex;
CString mtlName;
CString photoName;
C3dMaterial* pcurMtl=NULL;
float color[3];
while (mFile.ReadString(strTemp))
{
strTemp.Trim();
switch(char(strTemp.GetAt(0)))
{
case '#':
break;
case 'n':
{
tempIndex = strTemp.GetLength();
mtlName = strTemp.Right(tempIndex-7);
pcurMtl = C3dMaterial::Create(mtlName,
0.f, 0.f, 0.f, 1.00f,
0.f, 0.f, 0.f, 1.00f,
0.f, 0.f, 0.f, 1.00f,
0.f, 0.f, 0.f, 1.00f,
0.0f,
0.0f,
0.0f,
1.f);
ab.push_back(pcurMtl); //不出错
m_MaterialList.push_back( pcurMtl ); //出错?
}non-local static object 初始化顺序问题,4楼解释的很清楚,你那不叫声明,你又定义了,然后再CPP文件中导致没有初始化,用extern声明过来就不一样template<class _OutIt,
class _Diff,
class _Ty> inline
void __CLRCALL_OR_CDECL _Fill_n(_OutIt _First, _Diff _Count, const _Ty& _Val,
_Range_checked_iterator_tag)
{ // copy _Val _Count times through [_First, ...)
for (; 0 < _Count; --_Count, ++_First)
*_First = _Val;//停在这里
}// 头文件中的声明
std::vector<C3dMaterial*> m_MaterialList;