Archived

This topic is now archived and is closed to further replies.

Returning a template

This topic is 5118 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I''m quite new to templates, this is what i''m trying to do...
template
t CListManager::operator [](unsigned int i)
{
return m_data;
}

bool CVisualisation::RenderPrimitive(int id, D3DXVECTOR3 &pos)
{
return ((CGfxEntityPrimitive*)m_pPrimitiveList[id - 1])->Render(pos);
}

But it says i cannot convert from ''CListManager'' to ''CGfxEntityPrimitive *''. Any other way of doing this? Regards, bangz. http://www.bangz.co.uk

Share on other sites
I think that operator precedence is biting you in the ass here. Put in some parentheses to make it clearer to the compiler.

"Sneftel is correct, if rather vulgar." --Flarelocke

Share on other sites
Yup, silly mistake...

return ((CGfxEntityPrimitive*)(*m_pPrimitiveList)[id - 1])->Render(pos);

as m_pPrimitiveList is a pointer I needed to dereference it before i used the [] operator!

Thanks,
bangz.

http://www.bangz.co.uk