Original Post
Hi, I am using C++ and DirectX9 and Fmod. I am trying to set a pointer to point to an element in a vector. The element is a random directly accessed element. I get these compile errors: Sound.cpp(262) : error C2440: 'initializing' : cannot convert from 'std::allocator<_Ty>::value_type' to 'std::vector<_Ty>::iterator' with [ _Ty=CSoundManager::STREAMMUSIC ] and [ _Ty=CSoundManager::STREAMMUSIC ] No constructor could take the source type, or constructor overload resolution was ambiguous Anyone able to help?
////.H
struct STREAMMUSIC
{
//filepath of music
string m_sFilename;
//handle to a stream (music)
FSOUND_STREAM *m_streMusicHandle;
//operator to sort music struct
bool operator<(const STREAMMUSIC &Music) const {return m_sFilename<Music.m_sFilename;}
};
//list of all loaded music
static vector <STREAMMUSIC> m_lstLoadedMusicList;
//current music playing
STREAMMUSIC *m_pCurrentStreamMusic;
////.CPP
//set current music
vector<STREAMMUSIC>::iterator itLoadedMusic=m_lstLoadedMusicList[int((m_lstLoadedMusicList.size()+1)*rand()/(RAND_MAX+1.0))];
m_pCurrentStreamMusic=&(*itLoadedMusic);