Hi Dan, > > > TWSocketClient* Client = dynamic_cast<TWSocketClient*>(Sender); > > > AnsiString msg = Client->ReceiveStr(); > > > > The first line will execute, I think the second line will generate an > > exception here. I´m not sure. Did you have it into an exception block ? > > > > As far as I know the dynamic_cast is a kind of equivalent for ´is´ or > > ´as´ operators in Delphi and some other languages. It is not the same as > > a type cast. I even think it will evaluate to false (null) because > > Sender is of type TObject (yeah it "is" TWSocketClient, but compiler > > dont know that). > > A dynamic cast is safer. Yes its similar to Delphi´s as/is operators. In > this case, this a pointer dynamic cast (rather than a reference), it will > return null/nil if Sender isn´t really a TWSocketClient, and the code should > then check for this. An alternative is to use a reference: > > TWSocketClient& Client = dynamic_cast<TWSocketClient&>(Sender);
But Sender is a pointer - I didn't think you could typecast a pointer to a reference. Regards, Bevan
-- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be