Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. How to cast pointer from one type to another type

How to cast pointer from one type to another type

Scheduled Pinned Locked Moved Managed C++/CLI
c++tutorialannouncement
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aloktambi
    wrote on last edited by
    #1

    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++

    H N 2 Replies Last reply
    0
    • A aloktambi

      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++

      H Offline
      H Offline
      HZ_79
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • A aloktambi

        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++

        N Offline
        N Offline
        NrmMyth
        wrote on last edited by
        #3

        Create a copy constructor

        A 1 Reply Last reply
        0
        • N NrmMyth

          Create a copy constructor

          A Offline
          A Offline
          aloktambi
          wrote on last edited by
          #4

          but sir __gc class shall not declare a user-defined copy constructor,How to possible to create copy constructor

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups