Results 1 to 7 of 7

Thread: Off the wall question on VARs

  1. #1

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Ok this is a strange question that CyberCartsen and I have been discussing and we have not figured it out. I was wonder if some one else knew this. Or if anyone else even does these types of VARs.

    Its about VARs that are not local, and not really global. Example:

    a .h file
    PHP Code:
    ...
    extern int GlobalVar;

    void whateverfunction();
    ... 
    a .cpp file
    PHP Code:
    ...
    int GlobalVar;
    int notreallyGlobal;  //This is VAR at hand

    void whateverfunction()
    {
      
    int LocalVar;
    }
    ... 
    Ok now GlobalVar is of course a Global VAR through out your program. LocalVar is of course a Local VAR in that function. So what is notreallyGlobal called since it is only Global in that cpp? Is it still called Global?
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It's still a global, but you can only access it if you have a definition -- for example using extern.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Right but I only wanted that VAR to accessed by the functions in this cpp, thats why I did not extern it.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Since by default they're only file-global if defined at file scope (not inside a function or namespace), just call it global
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Thats the conclusion I came to, I just thought there might be another name for it like, Locally Global, or something
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Well, I've never heard them called anything different, so I don't know if there's a real name for them...although if you called them File Global people would probably know what you meant.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Hmm...Yeah I like that. That should work fine.

    Thanks.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


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