I have wrote program to test static and extern keywords in C++.
source1.cpp
#include "Header.h"
using namespace std;
static int num;
int main(){
num = 1;
cout << num << endl;
func();
}
source2.cpp
#include "Header.h"
using namespace std;
extern int num;
void func(){
num = 100;
cout << num << endl;
}
Header.h
#ifndef HEADER_H
#define HEADER_H
#include <iostream>
void func();
#endif
When i compile this program it gives me a link error.
error LNK2001, LNk1120 unresolved externals.
What is the reason to causes this Link error?