I currently have the code for a bowling program in C++ and I am very much a novice in C++ I need to use this program to develop and change it into my own, such as removing stuff too advanced and understanding how it works, but currently I am completely at a loss as there is very little in the main.cpp and something I do not understand at all other than it is checking what the OS the program is on, but I can't work out how to run this as the int main seems to reference it in some way
if possible can someone please point out the obvious as to why I cant remove it, tell me how to remove it, or atleast start me on my way to getting rid of it, I just want the main to intialise the program but as it stands I can't, further more, the program does not seem to want to debug or build regardless of what I do, but I have an .exe file that shows me the program works as its supposed to what am I doing wrong, I am currently using visual studio
The first thing main does is to extract the path to the application object file.
argv[0] contains the fully qualified object file name. How this is isolated into just a path name depends on the specific operating system. Mutliple methods are used to determine this. A compile time toggle is used to determine if the program was compiled on Apple. If not Apple, then whether Linux or Windows depends on whether a / or \ is found in the object file name.
If you want to remove the operating system dependency, then you need to change lines 8-20 accordingly. You may or may not want to remove the extraction of the pathname altogether since the extracted pathname is passed to Program's constructor (line 26), although _appDirPath does not appear to be used.
If this is not what you're asking, then please clarify your question.
I think you've just made it ever so slightly clearer, all the initial function is doing is seeing if the file path (where the program is run from) has a "/" or a "//" because of the differences between windows and mac file systems (to put it verrrrrryyy simply)
basically yes. I want to remove this, I don't want the "operating system dependency" as you've called it because it will only be run on Windows, I'm trying to heavily simplify the program.
I think the issue with just deleting the code is that the result of the function and int main, in main.cpp is then pushed to program.cpp which THEN initializes the "int initialize" function in BowlingGame.cpp which actually begins the program, I don't know what to remove or write to straight up initialize the BowlingGame function as I'm a dolt.
As I said above, the constructor for Program is expecting a path to the program object file, but as far as I can see it never does anything with that value. Since you haven't provided bowling.h, I can't tell if the BowlingGame class needs the application path.
So if the assumption is true that application path is not used, then you can eliminate lines 6-21, 25, 53, 67. Your constructor for Program then becomes:
I actually don't see any reason that the application needs to isolate the application path. If you attempt to open an unqualified file name, the run time will look in the directory where the object file is.
BTW, it's a good idea to avoid variable names that begin with _. Variables that begin with _ are reserved by the standard for use by the compiler.
I have now included the bowling.h and bowling.cpp if it helps you know what I need to do,
I am trying to remove the program.h/.cpp files completely if possible, as well as move on to remove a couple of the other files, but thats another story, Right now I can't see much use for the progam files other than cmaybe clearing the arrays upon shut down? I don't know?
Good instinct to remove the Program class. I don't see that it adds any particular value other than to tell you if the program is initialized or running.
Based on what you posted for bowlinggame.h, I would get rid of program.h and program.cpp and change main as folllows:
1 2 3 4 5 6 7 8 9
int main (int argc, char *argv[])
{ BowlingGame game;
game.initialize ();
while (game.update()) // continue until false is returned
;
game.shutdown ();
return 0;
}
That is fantastic!! It works completely! I had it working without the path nonsense, but now I can get rid of the progam files completely! Thank you so much!
Is there still any need for the int argc and char? in the title?