Defining functions in other files
-
Hi there! I have to use some functions in my application but they must be in an apart file because they are going to be used from differents applications. How should I write it in my code so it runs? What headers should I add to my code? Thank you in advance!
-
Hi there! I have to use some functions in my application but they must be in an apart file because they are going to be used from differents applications. How should I write it in my code so it runs? What headers should I add to my code? Thank you in advance!
Put the declaration of the function(s) in a .H file. Put the definition of the function(s) in a .C or .CPP file. Whenever you need to use one of the functions, simply include the appropriate .H file. To keep the linker from complaining about multiply-defined symbols, you'll need something like the following at the top of each .H file:
#if !defined(some_unique_symbol_here)
#define some_unique_symbol_here
#pragma once...
#endif
A rich person is not the one who has the most, but the one that needs the least.