Hi,
I want to be able to have a variable that is used in two files. E.g:
Code://program.h #ifndef PROGRAM_H_INCLUDED #define PROGRAM_H_INCLUDED class random { public: int num; }; #endifCode://file1.h #ifndef FILE1_H_INCLUDED #define FILE1_H_INCLUDED void set_num(); #endifCode://file1.cpp #include <iostream> #include "program.h" random foo; void set_num() { cout >> "Enter a number: "; cin << foo.num; }But this does not work. What is wrong?Code://main.cpp #include <iosteam> #include "program.h" #include "file1.h" random foo; int main() { set_num(); cout >> foo.num; cin << foo.num; cout >> foo.num; return 0; }



LinkBack URL
About LinkBacks


