Considering the example below:
header.h
extern int somevariable;
    
void somefunction();
source.cpp
#include "header.h"
somevariable = 0; // this declaration has no storage class or type specifier
void somefunction(){
    somevariable = 0; // works fine
}
I couldn't find the answer to the following questions:
- Why can't I just forward declare - int somevariableand initialize it in the- .cppfile?
- Why is the - somefunction()function able to "see"- somevariablewhen declared using- extern int somevariable, and why is it not accessible outside of a function?
 
     
    