A vector container declared in a different source file used in an "if" statement is out of scope? : I've created a source file that contains a number of data structures (maps, vector, array). Its header file is `#included` in the main-file. 

The main file looks like this: 

    #include "src1.h" //Where monkey() and vector<int> bar are declared
    
    main()
    {
        monkey(bar); // Calling monkey(bar) here is OK! Bar is visible
   
        ... 
    
        ifstream fp("foo.txt"); 
        if(fp.is_open())
        {
           std::string line; 
           while( getline(fp,line) )
           {
               monkey(bar); //'bar' is an undefined reference!
           }
        }
    }

And **src1.h**

    #ifndef SRC1_H
    #define SRC1_H

    extern std::vector<int> bar; 

    void monkey(std::vector<int> feces); 
  
    #endif

And **src1.cpp**
    
    std::vector<int> bar; 
    
    void monkey(std::vector<int> thrown_obj)
    { 
       ... //Iteration and dereferencing of "thrown_obj"
    }


I've accessed data structures that are declared in `src1.cpp` in a for-loop in the scope of main and *that* was fine. Something wonky is happening in this if-statement though. 

Compiler Error: 

    lab1.o: In function `main':
    /home/ubuntu/workspace/ECE597/Lab1/lab1.cc:105: undefined reference to `int_req'
    collect2: error: ld returned 1 exit status