Hello everyone, so I was messing around with Vexcode pro and I noticed that you can create headers and source files. I understand the difference between them and how to use them, but I noticed that you can create header files and source files in include or src. Is there a specific place to put them or does it matter and what is the best practice?
Generally I’d put headers in include directory and cpp files in src. I am not sure if it matters though, because you can also add multiple directories.
(Credit to 2158 for teaching me about file management and headers)
I am having trouble with my code. When it tries to read my source files it says that it can’t find them. I included them in my code, but it still won’t read it. Is it because I have my source code in src instead of include? If so, then how do I fix it?
Guess it wasn’t what I was thinking (I was thinking you could’ve made a file outside of the directories which is possible, but it doesn’t look like it). Does it cause a compilation error when you compile your code or something?
In C++, a variable name cannot start with a number. I assume the same would apply to the file names as well. It seems that the only file you have starting with a number is causing the issue so try changing that.
Not just bad practice, but it will generally make your code not compile. If your code does compile it probably will not link because there are multiple definitions of the same thing. All a #include statement does is tell the preprocessor to go find that file and stick it in where the #include is.
A header file is to create an access file and organize accessor variables to source files. When you create methods and variables in a source file to organize them, you can organize them more by creating header files in which the accessor variables are defined.
A header file is meant to keep code organized and provide function/variable declarations; this is different from function definitions. You can put code into headers, but it is generally bad practice unless it is something really tiny and trivial.
Header files are also where classes are typically created to allow them to be reused much more easily. If you go advanced enough to start creating classes, the header file is where it is the easiest to do so and is traditionally where it is done.