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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Global variables

Global variables

Scheduled Pinned Locked Moved Managed C++/CLI
c++databasehelpquestion
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.
  • J Offline
    J Offline
    Jose Vicente
    wrote on last edited by
    #1

    Hello. I'm writing a managed C++ application, and I have created a __gc class that acts as a Cache between the Database and my application. I want that this caché can be accesed from anywhere in the application. So I tried to do this. In stdafx.h extern CCache* g_pCache; In stdafx.cpp CCache* g_pCache = new CCache (); and I have the following error message: error C3145: 'g_pCache' : cannot declare a global or static managed type object or a __gc pointer Its possible to define a variable of a managed type that its global ? How ? Thanks. :confused:

    N 1 Reply Last reply
    0
    • J Jose Vicente

      Hello. I'm writing a managed C++ application, and I have created a __gc class that acts as a Cache between the Database and my application. I want that this caché can be accesed from anywhere in the application. So I tried to do this. In stdafx.h extern CCache* g_pCache; In stdafx.cpp CCache* g_pCache = new CCache (); and I have the following error message: error C3145: 'g_pCache' : cannot declare a global or static managed type object or a __gc pointer Its possible to define a variable of a managed type that its global ? How ? Thanks. :confused:

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      The alternative is to have your globals as static members of some class. That way they can be accessed anywhere. Nish


      Extending MFC Applications with the .NET Framework [NW] (coming soon...) Summer Love and Some more Cricket [NW] (My first novel) Shog's review of SLASMC [NW] Come with me if you want to live

      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