My knowledge of C++ is limited. I understand this; the main CPP file is where I store my code. Problem is, my current CPP is becoming huge, way too many functions. When I research header files and other cpp files on this site and others, it seems they use other commands for them like "void main()" or things other than "main". These typically use other weird commands and variables etc that I just don't get...yet. So I'm hoping someone can at least give me a SIMPLE example. If one does not exist, then I understand that I'd then have to research a buttload of stuff to understand it.
*Note: I am NOT asking someone to go through all the "void" and other commands in detail, hoping there's an easier way*
My question is this; how do I just make the simplest file so that any function I call is the same as if it were stored in my main file? Where little (or preferably NO modification to any variable, none of the "public" or "private" stuff is of concern nor needs to be declared).
IE:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
int addsometothis()
{
a = 5;
b = 7;
z = dothis[a][b];
dothis[y][b] = z;
return 0;
}
int main()
{
addsometothis();
cout << "End of Program" << endl;
return 0;
}
|
That is an example of my program. It isn't the program, but just meant as a basic example. If you were to cut and paste my "addsometothis()" function to a file, told me what file it was called, how to include it into my main cpp file, that would answer my question.
or do all I need to do is add a .cpp file to my project and put this into it:
1 2 3 4 5 6 7 8 9 10
|
int addsometothis()
{
a = 5;
b = 7;
z = dothis[a][b];
dothis[y][b] = z;
return 0;
}
|
And then I would be able to call it from any other function throughout my program? Or would it have to be a header file? I just want to break it up into other files so it is more organized and I no longer have over 100 functions staring at me across the void of my desk whenever I'm going through it.