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. pointer to struct

pointer to struct

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++tutorial
3 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.
  • S Offline
    S Offline
    skullnite
    wrote on last edited by
    #1

    hi, um i am not sure if this is the right spot to post but i am having a small problem in c++. I have a class that holds a pointer to a struct. struct somestruct { someval }; class someclass { somestruct* pointer; }classpointer*; when i do this: classpointer->pointer->someval = something; i get a error i have no idea how to fix it thanks

    I M 2 Replies Last reply
    0
    • S skullnite

      hi, um i am not sure if this is the right spot to post but i am having a small problem in c++. I have a class that holds a pointer to a struct. struct somestruct { someval }; class someclass { somestruct* pointer; }classpointer*; when i do this: classpointer->pointer->someval = something; i get a error i have no idea how to fix it thanks

      I Offline
      I Offline
      Indrawati
      wrote on last edited by
      #2

      The default member access for a class is private, so you can't access pointer outside of the class unless you declare it as public. class someclass { public: somestruct* pointer; }classpointer*;

      1 Reply Last reply
      0
      • S skullnite

        hi, um i am not sure if this is the right spot to post but i am having a small problem in c++. I have a class that holds a pointer to a struct. struct somestruct { someval }; class someclass { somestruct* pointer; }classpointer*; when i do this: classpointer->pointer->someval = something; i get a error i have no idea how to fix it thanks

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #3

        to add to the other answer, I assume that point is actually allocated ? anyway, is it a compilation error or a runtime error ?


        Maximilien Lincourt Your Head A Splode - Strong Bad

        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