First post !
Hey ! i dont want to be a jerk by making my first post a question and not a reply buuut...
So i am trying to get back into programming as a hobby i havent done it since highschool ! i used a little c# in grade 12 but dont remember much. Anyway im trying to learn c++ now and am a little stuck, probly a simple fix but here it is.
i am just mucking around and trying to make a simple program to just ask if you want to use my simple calculator "calc extreme" or if you want to retrun to the start of the program etc.. anyway when i compile it i get a error in this part of the code..it says main is not declaired in this scope, whgat i dont get is that i call the old member and membername and dotn get that error but when i want the program to return to the main func it gives a error ? i tried to move the main funct around and it didnt seem to help. any one who can shine some light on a newbie i would be so grateful!
cout<<"Welcome back to the club!\n";
cout<<"What can we do for you today?\n";
cout<<"1-Calculator extreme\n 2-main menu: ";
//cout<<"please try again";
cout<<"Welcome to the club\n";
cout<<"Are you a new member? (Y/N)";
if ((member=='Y') || (member=='y'))
else if ((member=='N') || (member=='n'))
cout<<"Please try again\n";
Err... before you proceed:
- Indent your code properly.
- Use a loop instead of calling the global main function recursively.
- Do not use goto. In this case, a loop will suffice.
- Post the smallest and simplest compilable program that demonstrates the problem. If the problem is a compile error, then post the smallest and simplest program that you expect to compile but which does not, and then also post the error message.
You should address what laserlight said. But I can give you insight on why it fails.
The compiler parses the source file top to bottom. So when it encounters main inside oldmember, it hasn't been defined yet. So the compiler barks.
To fix it, one would usually put prototypes of each function at the top of the source file. However, main is special, so you shouldn't call it recursively.
Also, there is no shame in making a first post with a question. That is what people usually do. Come for help. So they register and they post a question. Perfectly normal.
sweet, thanks for the help!
So indenting just makes it look clean correct ?
Indenting makes the code readable, pretty and helps find bugs, such as misplaced braces.