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. C / C++ / MFC
  4. Can't convert struct hi to Chi*

Can't convert struct hi to Chi*

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
4 Posts 4 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.
  • K Offline
    K Offline
    kamalesh82
    wrote on last edited by
    #1

    Below i'm trying to give my code structure, so that it can understandable I've a class named "Chi", i've taken a ptrvariable to that class(hi), say tp; tr, is simple class variable( of "hi") now i've a structure called "hi"... i've a list to store the all structure variable.... now i want to store the tr(variable of Chi) in that list, nd then it gives me the error...[Can't convert struct hi to Chi*] my code in brief:: class Chi:public someclass {...... ......}// this is the cpp file in .h file i declare a variable of class Chi, and i have struct hi {....... ........} it' ll very plesure to me, if ny body let me know the exact way to store in this way........ ok...Good day to all off u......... kamalesh

    C K 2 Replies Last reply
    0
    • K kamalesh82

      Below i'm trying to give my code structure, so that it can understandable I've a class named "Chi", i've taken a ptrvariable to that class(hi), say tp; tr, is simple class variable( of "hi") now i've a structure called "hi"... i've a list to store the all structure variable.... now i want to store the tr(variable of Chi) in that list, nd then it gives me the error...[Can't convert struct hi to Chi*] my code in brief:: class Chi:public someclass {...... ......}// this is the cpp file in .h file i declare a variable of class Chi, and i have struct hi {....... ........} it' ll very plesure to me, if ny body let me know the exact way to store in this way........ ok...Good day to all off u......... kamalesh

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      kamalesh82 wrote:

      I've a class named "Chi", i've taken a ptrvariable to that class(hi), say tp; tr, is simple class variable( of "hi")

      :omg: This is not clear at all: it is really confusing what you are trying to explain: Chi, hi, tp, tr, "hi", ... :confused: Put some code (with a short description if required) and a precise question.


      Cédric Moonen Software developer
      Charting control

      S 1 Reply Last reply
      0
      • C Cedric Moonen

        kamalesh82 wrote:

        I've a class named "Chi", i've taken a ptrvariable to that class(hi), say tp; tr, is simple class variable( of "hi")

        :omg: This is not clear at all: it is really confusing what you are trying to explain: Chi, hi, tp, tr, "hi", ... :confused: Put some code (with a short description if required) and a precise question.


        Cédric Moonen Software developer
        Charting control

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #3

        I couldn't make head or tail out of it either. Steve

        1 Reply Last reply
        0
        • K kamalesh82

          Below i'm trying to give my code structure, so that it can understandable I've a class named "Chi", i've taken a ptrvariable to that class(hi), say tp; tr, is simple class variable( of "hi") now i've a structure called "hi"... i've a list to store the all structure variable.... now i want to store the tr(variable of Chi) in that list, nd then it gives me the error...[Can't convert struct hi to Chi*] my code in brief:: class Chi:public someclass {...... ......}// this is the cpp file in .h file i declare a variable of class Chi, and i have struct hi {....... ........} it' ll very plesure to me, if ny body let me know the exact way to store in this way........ ok...Good day to all off u......... kamalesh

          K Offline
          K Offline
          KarstenK
          wrote on last edited by
          #4

          You have to understand the sense behind converting data. For instance: class A : public B { } class C //or struct { } You can: A *p = new A; B *p1 = (B*) p; //because A inherits B !!! you cant B *p2 = (B*) new C;///Bullshit C isnt a B (or A) because C is NOT a B. You can store any data type in a void*, but you have to cast it with a legal cast to a object. I guess you a learning working with pointers? X| Greeting from Germany

          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