Use variables from file A in file B in C++
-
Hello,
I am currently working on a project and I have a problem with variables. The project is split into several independent .cpp files and I would like to retrieve variables from the first file to use them in the second file but I don't know how to do this.
In short, I would like to use variables from file A in file B by means of a pointer pass.
If you have any information on how to do this, I'd love to hear from you and thank you in advance !TheGreenTank
-
@TheGreenTank
Well, at the end of the day however you do it you will want to#include "A.h"
intoB.cpp
. That will allowB
to access things fromA
. Whatever is declaredpublic
inA.h
can be accessed fromB
. -
@Pueablo said in Use variables from file A in file B in C++:
@JonB Don't forget to declare the variables as public.
?
@JonB said in Use variables from file A in file B in C++:
Whatever is declared
public
inA.h
can be accessed fromB
.