Archived

This topic is now archived and is closed to further replies.

kaiel090x

Just when I thought I had it....

Recommended Posts

I wrote my first script for a Battle System. Nothing big really. Its just a Console Based C++ script, and for some reason, my code warrior compiler is giving me this compilation error:illegal function definition. All the way at the top of the code is the prototype, and the declarations at the bottom. Its saying the error is at the bottom, underneath the function name, by the bracket { on both function. I had over 80 errors and I fixed them all, my brain may just be a bit dead. If someone could help me, I would be thankful.(its a bit messy, you need to be somewheres near a 6 year MIT graduate or rocket scientist to understand it, lol, its my first one)The error is all the way on the bottom. There is a comment next to it. I would have just given the bottom, but I think the error is somewhere else in the script and detected on the bottom. #include #include #include using namespace std; void AtkMnu(); int Selection(); // The main() function. int main() { int yLife = 99; int eLife = 60; int yDmg; int eDmg; bool yHitMiss=0; bool eHitMiss=0; AtkMnu(); int selection; selection = Selection(); while(eLife>=1) { switch(selection) { case 1: srand (time (0)); bool yHitMiss = rand () % 2; bool eHitMiss = rand () % 2; if((yHitMiss == 1) && (selection == 1)) yDmg = yLife / 3; eLife= eLife - yDmg; cout <<"You attacked and did"<< yDmg <<"damage. Your enemies life is"<> selection; return selection; }//and it says this bracket is an error and the error said is:illegal function definition. ~ from the depths of the ocean Edited by - kaiel090x on August 10, 2001 10:53:46 PM

Share this post


Link to post
Share on other sites
You will have to tell us which of those numerous lines the error is on.

Hint: First, post a little code, such as 5 lines or so, including the line that the error indicates. Then post extra code later if posters indicate that they need to see more.

Share this post


Link to post
Share on other sites
i just forgot to add the ending bracket for the while loop.and by the way, is that script considered good at all? or something someone could actually use in a game. Or, rather, is it good for someone first C++(gaming) app?)

~ from the depths of the ocean

Edited by - kaiel090x on August 10, 2001 11:01:02 PM

Edited by - kaiel090x on August 11, 2001 11:54:12 AM

Share this post


Link to post
Share on other sites
hey thanks. I figured it out the same time you sent the reply. Thanks for actually taking the time to help me though.

quote:
Original post by Elixir
You didn''t close main() (or rather, your while loop). This why its good to use proper spacing and tabbing.





~ from the depths of the ocean

Share this post


Link to post
Share on other sites