CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2001
    Posts
    30

    Declaring global class instances

    While making my program, I decided that I want to make a dialog class that would pop up when a button is clicked, and then retain all of the values entered until the program exits. Where and how would I go about declaring this class? Would I have to declare it in the main dialog header/cpp file? I have tried making an instance in several places, but I get errors. This is what I add:

    CDlgRoot root; // class that I want to make



    When I do this, I get 12 errors saying something along the lines of: "missing ';' before identifier 'root'" , "'CDlgRoot' : missing storage-class or type specifiers" , and "'root' : missing storage-class or type specifiers"
    Thank you in advance.


  2. #2
    Join Date
    Dec 2000
    Posts
    15

    Re: Declaring global class instances

    Hi
    Its not so clear to we what you are trying to do
    but from what i have been reading i understand that u are trying to create a new dialog and make it show
    himself any time you press a button if i am right contact me via my email : nisims@hotmail.com and i will try to help u
    have a nice day



  3. #3
    Join Date
    Sep 1999
    Location
    USA
    Posts
    178

    Re: Declaring global class instances

    try this

    CDlgRoot* m_dlgRoot = NULL; //declare this globally inside your class

    CDlgRoot::CDlgRoot()
    {
    m_dlgRoot = this; //do this inside your constructor
    }


    //now wherever you need to use this dialog, just use:
    extern CDlgRoot* m_dlgRoot;
    m_dlgRoot->YourFunction





  4. #4
    Join Date
    May 2001
    Posts
    31

    Re: Declaring global class instances

    It is not very clear what you have in your code. But just try #include "CDlgRoot.h" or whatever header file you have for this class and insert it at the file where you declare the

    CDlgRoot root; //





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