How to cast pointer from one type to another type
-
i want to typecast System::Byte* to class type pointer __gc class Update {public: unsigned short Posn; short Pres; short Temp1; short Temp2; Byte status; }; Byte *data; i am receieving data from one function i want to typecast this Byte pointer to Update class pointer type. how it is possible in managed c++
-
i want to typecast System::Byte* to class type pointer __gc class Update {public: unsigned short Posn; short Pres; short Temp1; short Temp2; Byte status; }; Byte *data; i am receieving data from one function i want to typecast this Byte pointer to Update class pointer type. how it is possible in managed c++
Hi, I am not an expert, but I think the code below or a similar code should match: Update* upd = new Update(); upd->Posn = data[0] + 256*data[1]; upd->Pres = data[2] + 256*data[3]; upd->Temp1= data[4] + 256*data[5]; upd->Temp2= data[6] + 256*data[7]; upd->status=data[8]; This is a simple way to do your cast by hand. Thanks,
HZ
-
i want to typecast System::Byte* to class type pointer __gc class Update {public: unsigned short Posn; short Pres; short Temp1; short Temp2; Byte status; }; Byte *data; i am receieving data from one function i want to typecast this Byte pointer to Update class pointer type. how it is possible in managed c++