yep, you're right. I have an object in main(), that object has a template I have created which HAS a map<> template. then in a function i pass that first object and access the map object and use the add() function to add another item. can i not use a pointer with an array like that?
Quote:Original post by EvilKnuckles666
yep, that's the error i'm getting, it's coming up in a new window and giving me that error i posted in i think my second post here. but i'm using strictly C++ not managed or anything
So I repeat, why are you getting that error? If you're strictly using good ol' C++, with .NET nowhere to be found, you should never see the text "System.NullReferenceException" (unless of course you put it in your project yourself).
If you are, then there's something else going on. A null pointer in C++ gives you an access violation, not a NullReferenceException.
Check your project settings to make sure you're not building a .NET application.
well, the error isn't really in MY code, it's in the map<> template code, it the head heap or something like that, not really sure how the code behind that works, i just know how to use it.
but no, i KNOW i'm not using .NET; if it's in the project settings i wouldn't know there, where would that be?
but no, i KNOW i'm not using .NET; if it's in the project settings i wouldn't know there, where would that be?
Quote:Original post by EvilKnuckles666
yep, you're right. I have an object in main(), that object has a template I have created which HAS a map<> template. then in a function i pass that first object and access the map object and use the add() function to add another item. can i not use a pointer with an array like that?
Show the relevant code in main() and the other function, please.
there's a whole lot to my code... i have a pretty full game engine.. but here's the code that shows it.
bool cGun::Fire(Wrath2D::cWUtility::sWVector3D Pos){ if (Wrath2D::cWUtility::Math.GetTicks() - m_lCurTimeFired >= m_lDelay) { Wrath2D::cWTextureSprite *pTexSpr = NULL; Wrath2D::cWCollisionObject *pCollObj = NULL; pTexSpr = m_pGraphics->EntityManager.AddUniqueSprite("Bullet"); pTexSpr->Init(m_pBulletType->pTexture, m_pBulletType->Rect, Pos); pTexSpr->SetDirection(Wrath2D::cWUtility::Math.GetVectorAngle( Wrath2D::cWUtility::sWVector2D(0.0f, 0.0f), m_pBulletType->Velocity)); pTexSpr->SetVelocity(m_pBulletType->Velocity.Length()); pCollObj = m_pEffects->CollisionSystem.AddUniqueObject("Bullet"); pCollObj->Init(pTexSpr, BULLET); pCollObj->SetCollisionCircle(Wrath2D::cWUtility::sWVector2D(0.0f, 0.0f), float(pTexSpr->GetFrameHeight())/2.0f); return true; } return false;} Type* AddUnique(std::string RefName) { typedef std::map <std::string, Type*> mymap; // the next set of code is an attempt to see what crashes. // if the next set of code doesn't crash, then it has no side effects: mymap map_test; // a stand alone temp map map_test.find(RefName); // a failed search mymap::iterator Iter1 = map_test.find(RefName); // a failed search with assign map_test[RefName] = 0; // put something in the temp map map_test.find(RefName); // a successful search Iter1 = map_test.find(RefName); // a successful search, with assign m_MapList.find(RefName); // the search in the real map, but with no assignment // Ok, and now we try what the original code did: mymap::iterator Iter = m_MapList.find(RefName); // does this crash? Type *newType = new Type(); //std::map <std::string, Type*>::iterator Iter; long i=1; std::stringstream ss; ss << RefName << i; Iter = m_MapList.find(ss.str()); while (Iter != m_MapList.end()) { i++; ss.str(""); ss << RefName << i; Iter = m_MapList.find(ss.str()); } cWUtility::ErrorLog.Write(ss.str()); m_MapList.insert( std::pair<std::string, Type*>(ss.str(), newType)); return newType; };
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement