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. Difference between "->" and "."

Difference between "->" and "."

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++
2 Posts 2 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.
  • C Offline
    C Offline
    crushinghellhammer
    wrote on last edited by
    #1

    I have some experience programming in C# .NET but am new to C++. Could somebody please tell me what the difference between "->" and "." are in C++, which is to say: when is it appropriate to use someclass.whatever and when is it correct to use someclass->whatever. Thanks!

    R 1 Reply Last reply
    0
    • C crushinghellhammer

      I have some experience programming in C# .NET but am new to C++. Could somebody please tell me what the difference between "->" and "." are in C++, which is to say: when is it appropriate to use someclass.whatever and when is it correct to use someclass->whatever. Thanks!

      R Offline
      R Offline
      RNEELY
      wrote on last edited by
      #2

      "ptrsomeclass->whatever" is shorthand for "(*ptrsomeclass).whatever" you must have a pointer to someclass to use -> you must have a direct instance of someclass to use . for example: someclass someobject; someclass* ptrobject = &someobject; //&=addressof someobject.whatever; (*ptrobject).whatever; //* dereferences address ptrobject->whatever; // same as line above Sincerely, -Ron

      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