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. C++ Global data structures

C++ Global data structures

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
3 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.
  • P Offline
    P Offline
    Polity4h
    wrote on last edited by
    #1

    Hi, I'm currently working on a singel project witch includes many threads. There will be one class which implements the input and output. Next to that, there will be a single object (GLOBAL!) which stores information. more specific, both the IO class and the threads will communicate with the global storage object, so where to declare it? The application is fully written in C++ and totally OO Thanks already! Koen B

    J 1 Reply Last reply
    0
    • P Polity4h

      Hi, I'm currently working on a singel project witch includes many threads. There will be one class which implements the input and output. Next to that, there will be a single object (GLOBAL!) which stores information. more specific, both the IO class and the threads will communicate with the global storage object, so where to declare it? The application is fully written in C++ and totally OO Thanks already! Koen B

      J Offline
      J Offline
      Jun Du
      wrote on last edited by
      #2

      In your case, implement the global data object as a Singleton class. Whenever you want to use the object, call the specific static method to get its instance. It does not matter where you declare it first.

      Best, Jun

      P 1 Reply Last reply
      0
      • J Jun Du

        In your case, implement the global data object as a Singleton class. Whenever you want to use the object, call the specific static method to get its instance. It does not matter where you declare it first.

        Best, Jun

        P Offline
        P Offline
        Polity4h
        wrote on last edited by
        #3

        thanks, i've declared one static object already and used the extern keyword in nearly every file. but i see yours is better

        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