When you do this, you need to set up your code like so:
file2.cpp
Code:
int var1;
int var2;
float var3;
int myFunc(int pass1,int pass2)
{
return pass1+pass2;
}
file2.h
Code:
#ifndef FILE2_H_
#define FILE2_H_
extern int var1;
extern int var2;
extern float var3;
int myFunc(int pass1,int pass2);
#endif
file.cpp
Code:
#include "file2.h"
#include <iostream.h>
int main()
{
var1=3;
var2=5;
cout << myFunc(var1,var2) << endl;
cout << "var3==" << var3 << endl;
return 0;
}
So you basically have a triangle setup for your code:
Code:
file2.h
/ \
file.cpp file2.cpp
-hope that helps