The following statement gives me compiler error as a surprise to me:
BaseClass& base;
if (((const AClass*) ptr = dynamic_cast<const AClass*> (&base)) != NULL)
{
...
}
GCC 4.1.2 says ptr isn't defined as an error. However an ordinary defintion and assignment would work. Such as
if (const int* ptr = f())
So what makes it not working for the above code segment?
No this isn't a duplication of the other thread as I have pointed out the simple case works but not such a case. If you think it's a duplication can you at least point out why the above one doesn't work then.