atch 0 Junior Poster in Training

Hi,
I tried to be clever and wrote template (body below), and something is not working as I would like it to. I have to explicitly cast template parameter on desired type instead of function recognize type (by id() method provided in class object); I don't understand why is it. It's look like switch(_what->id()) doesn't work which in result gives error when I don't use explicit casting.
Any help will be most appreciated.

[code=c++]
//places an object (_what) into cave
template<typename T>
		T* Cave::_place_it(T* _what, Hump_The_Wumpus::room::Cave* cave)
		{
			cerr << to_string(_what->id());
			switch(_what->id())
			{
			case ID::WUMPUS:
				cave->wumpus(reinterpret_cast<Hump_The_Wumpus::prototype::Monster*>(_what));
				break;
			case ID::HERO:
				cave->hero(reinterpret_cast<Hump_The_Wumpus::prototype::Monster*>(_what));
				break;
			case ID::BAT:
				cave->bat(reinterpret_cast<Hump_The_Wumpus::prototype::Monster*>(_what));
				break;
			case ID::SHOTGUN: 
			case ID::BFG:
			case ID::LIGHTNING:
			case ID::ROCKETLAUNCHER:
			case ID::NAILGUN:
			case ID::GRANADES:
			case ID::PLASMAGUN:
			case ID::RAILGUN:
				cave->gun(dynamic_cast<Hump_The_Wumpus::weapon::Gun*>(_what));
				break;
			case ID::BOTTOMLESS_PIT:
				cave->_bottomless_pit = true;
				break;
			}
			return _what; ///change it to correct value
		}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.