CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Gloabal objects

  1. #1
    Join Date
    Aug 1999
    Posts
    8

    Gloabal objects

    Is there anyway in C++ of declaring a global object? I want to create a single workspace object for my DB appliction, and access this object from my entire application. Any way of achieving this?
    Regards, Phil Messenger


  2. #2
    Join Date
    Apr 1999
    Location
    Toronto, ON
    Posts
    713

    Re: Gloabal objects

    Are your "entire app" and "DB app" different exe-s?
    If so, what do you want? If you want just exchange by messages beetwen apps you can registr
    your custom messages for the exchange.
    Another way - create separate thread and exchange
    with this thread by SetEvent, while the thread will be "WaitForMultipleObject"


    Dmitriy, MCSE

  3. #3
    Join Date
    Jul 1999
    Location
    Uitca, NY
    Posts
    120

    Re: Gloabal objects

    You declare a global anything by putting it in a .cpp file outside of any function, such as directly after you #includes. If you need to use the global in another .cpp file use the 'extern' keyword in front of the declaration. No redefinition is needed. You do seem to be defeating the purpose of object oriented programming, however. OOP procedures are developed to minimize problems, so following them will make life easier (or at least programming). Try keeping your workspace object in your CDocument class and access it from there.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured