Is there any difference between Windows and MAC to use dynamic_cast?

There are two class like A and B:
class A
{
public:
virtual ~A(){}
};

class B: public A
{
public:
B();
virtual ~B();
}
//....// definition of class B

When i use them like this:


void foo(A* a)
{
//....
B* b = dynamic_cast<B*>(a);
if(NULL == b) //// <== HERE it the issue
return;
//....
}

A* pa = new B();
foo(pa);

It works well on Windows, but i always get a NULL object pointer of B (please see the line "//// <== HERE it the issue" is in) on MAC.
I googled but can get effect solution, i guess there should be some difference between Windows and MAC in using dynamic_cast, could someone tell me that?

In addition, I tried the following code in foo(A*a):
cout<<typeid(*a).name()<<endl;
and i got the name "B", looks like there should be no problem with object a. BTW, i am using xCode on MAC.

Please help.

Thanks.
Topic archived. No new replies allowed.