You probably shouldn't use type-codes and switch/downcasts for this. Instead, put your object-specific code into a virtual method or (depending on the problem at hand) use a visitor pattern. Your current approach will probably look something like this in the end:
int price = 0;
if (obj->get_type_str() == "armor")
{
price = 1000 + ((Armor *)obj)->get_durability() * 100;
}
else if (obj->get_type_str() == "ninjasword")
{
price = 5000 * ((NinjaSword *)obj)->get_damage();
}
else if (obj->get_type_str() == "bfg")
{
price = 20000;
}
shop->show_price(price);
The problem is, that this isn't very extensible. Instead of defining the price of an object along with the object, it will be littered around the code. A better way would be to provide a virtual method get_price(), that can do this:
class GameObject
{
public:
virtual ~GameObject() {}
virtual int get_price() const = 0;
};
class Armor: public GameObject
{
public:
virtual int get_price() const
{
return 1000 + durability * 100;
}
private:
int durability;
};
class NinjaSword: public GameObject
{
public:
virtual int get_price() const
{
return 5000 * damage;
}
private:
int damage;
};
class Bfg: public GameObject
{
public:
virtual int get_price() const
{
return 20000;
}
};
Now your object-specific code stays in the object and the previous code example simply becomes:
shop->show_price(obj->get_price());
If the code in question doesn't really belong to the object, this may be a case for the Visitor pattern.