#include <string>
#include <iostream>
#include <typeinfo>

using std::string;
using std::cout;

class shape {
public:
	virtual void dummy(){} // typeid works only for polymorphic classes
	void draw() {
		// name() returns const char* "{name_length}{name}"
		string type = typeid(*this).name(); 
		if(type == "8triangle") { cout << "..drawing triangle.."; }
		else if(type == "6circle") { cout << "..drawing circle.."; }
		// …
		else { cout << "ERROR: type not recognized (usually, throws an exception)"; }
	}
};

class triangle : public shape { };

int main() {
	shape *pobj = new triangle;
	pobj->draw();
	delete pobj;

	return 0;
}
