Thread: extern keyword

  1. #1
    Shadow12345
    Guest

    extern keyword

    what is the extern keyword for.

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    317
    extern allows you to use global variables defined in one file( remember they have file scope) in another file. For example:
    Code:
    //file 1
    int Cats = 5
    void printcats(){
            cout<<Cats;
    }
    
    //file 2
    
    extern int Cats //declare variable in current file
    void ShowCats(){
            cout<<Cats;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. extern classes
    By Swordsman in forum C++ Programming
    Replies: 1
    Last Post: 05-07-2008, 02:07 AM
  2. usage of extern keyword
    By ilikepure in forum C++ Programming
    Replies: 2
    Last Post: 09-26-2007, 06:24 PM
  3. Replies: 16
    Last Post: 10-29-2006, 04:04 AM
  4. extern keyword
    By trekker in forum C Programming
    Replies: 7
    Last Post: 06-01-2005, 01:31 PM
  5. extern keyword and structures
    By GuitGentlyWeeps in forum C Programming
    Replies: 2
    Last Post: 01-30-2002, 06:02 AM