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. Reference class from global

Reference class from global

Scheduled Pinned Locked Moved C / C++ / MFC
sysadmintutorialquestion
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.
  • O Offline
    O Offline
    Oliver123
    wrote on last edited by
    #1

    I have a fragment of code as an example, and I'm trying to figure out what it does and how. void WINAPI CLeft::Abc(LinkPtr pData) { g_Spec().Xyz(pData); } I know CLeft::CLeft is a global outside of any class. It receives callbacks from a server. I know Xyz is in a class. I know the pointer pData is being passed. I think both Abc and Xyz are defined in the same file. I'm not sure what g_Spec().Xyz()really is. I'm trying to figure out how and where one defines g_Spec().Xyz(pData)so it can 1)be referenced by Xyz 2)be a class or within a class Anything look familiar? I really don't know if there is enough here to provide sufficient information. I am currently using the following and don't like it. It seems too complex, but that's how I got it to work. Abc is outside any class. Xyz is a function in CNewDlg. void WINAPI Abc(LinkPtr pData) { ((CNewDlg*)AfxGetApp()->m_pMainWnd)->Xyz(pData); <---I don't like this } Thanks

    J 1 Reply Last reply
    0
    • O Oliver123

      I have a fragment of code as an example, and I'm trying to figure out what it does and how. void WINAPI CLeft::Abc(LinkPtr pData) { g_Spec().Xyz(pData); } I know CLeft::CLeft is a global outside of any class. It receives callbacks from a server. I know Xyz is in a class. I know the pointer pData is being passed. I think both Abc and Xyz are defined in the same file. I'm not sure what g_Spec().Xyz()really is. I'm trying to figure out how and where one defines g_Spec().Xyz(pData)so it can 1)be referenced by Xyz 2)be a class or within a class Anything look familiar? I really don't know if there is enough here to provide sufficient information. I am currently using the following and don't like it. It seems too complex, but that's how I got it to work. Abc is outside any class. Xyz is a function in CNewDlg. void WINAPI Abc(LinkPtr pData) { ((CNewDlg*)AfxGetApp()->m_pMainWnd)->Xyz(pData); <---I don't like this } Thanks

      J Offline
      J Offline
      jhwurmbach
      wrote on last edited by
      #2

      Oliver123 wrote:

      I'm not sure what g_Spec().Xyz()really is.

      From its name it semms to be a global, and from its use I think it could be a global function, returning the reference to a singelton-instance of a class providing a function called Xyz, which takes a parameter that very well could be a LinkPtr.

      Oliver123 wrote:

      void WINAPI Abc(LinkPtr pData) { ((CNewDlg*)AfxGetApp()->m_pMainWnd)->Xyz(pData); <---I don't like this }

      Have you considered sending a user defined message?


      Failure is not an option - it's built right in.

      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