+ 3

(C++) extern class?

lets say i have 3 files. file1.cpp file2.cpp file3.h file1.cpp is contain main function and a class named "game". and "game" class need "player" class. so i wrote "player" class in file2.cpp. file3.h is containing some useful functions (like index, convert data types). so how to share "player" class into file1.cpp? i know it can be done easily with putting "player" class in file3.h or put #include "file2.cpp" in file1.cpp, but i wont. i just want to know. (just like extern class)

14th Jan 2018, 2:58 AM
Kevin AS
Kevin AS - avatar
4 Answers
+ 1
now im using c++ complier. im not sure but in terminal i can type c++ file1 file2 -o file_output
14th Jan 2018, 3:15 AM
Kevin AS
Kevin AS - avatar
+ 1
@jamie we dont need to include file2.h in file2.cpp?
14th Jan 2018, 3:26 AM
Kevin AS
Kevin AS - avatar
+ 1
basically that puts player class in header file. but i think that is the only way...thanks
14th Jan 2018, 3:31 AM
Kevin AS
Kevin AS - avatar
0
https://www.programiz.com/cpp-programming/library-function/cstdio/fscanf i read that. im not sure i think fscanf is only sharing variable
14th Jan 2018, 3:10 AM
Kevin AS
Kevin AS - avatar