Let's assume I have 3 cpp-files:
Main.cpp
First.cpp
Second.cpp
Now i want to use functions from First and Second in Main. Is there something to complain about, if I used only one header-file for both cpp-files and their functions?
Could there be any problems, when using the header-file in First, because I need a Function from Second in First?
Adding a Header File works the same as how we added another CPP source file (Square.cpp) NOTE: Use a .h suffix when naming your header files. Create a new item. By right clicking Project in solution explorer then click Add and in next option menu click on new item. This time select Header File (.h) File.
As far as C++ goes, there won't be any issues with using one header file and splitting the actual implementations of the functions between 2 files.
There are of 2 types of header file: 1 Pre-existing header files: Files which are already available in C/C++ compiler we just need to import them. 2 User-defined header files: These files are defined by the user and can be imported using “ 3 include”. More ...
Although Visual C++ only edits one header file for any given .RC file, Visual C++ supports references to symbols defined in additional read-only header files. Using the Resource Includes command from the View menu in Visual C++, you can specify any number of additional read-only header files as Read-Only Symbol Directives.
As long as you follow the ODR - One Definition Rule and every declaration is consistent, you will be fine.
Headers are usually meant to provide declarations for functions and other stuff, the linking phase (except when there's something a bit more involved like templates) will take care of resolving those dependencies.
I'm not saying anything on the design - not enough info provided.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With