I'm a bit newbie in c++ but why this code prints that the queue item is not a child while I created him as a child:
class Parent
{
public: virtual const char* getName() { return "Who is your daddy?"; }
};
class Child : public Parent
{
public: virtual const char* getName() { return "La gente esta muy loca?"; }
};
int _tmain(int argc, _TCHAR* argv[])
{
std::deque<Parent> queue;
queue.push_back(Child());
Parent* p = &queue.back();
if (dynamic_cast<Child*>(p) == 0) { std::cout << "I am not child"; }
else { std::cout << "Welcome, son"; }
std::cin >> c;
return 0;
}