|
| 18 Jan 2017 07:36 PM |
Sorry its not scripting, but apparently, you can only ask the one question on stack overflow a day, and frankly, the people there are a whole lot more rude than they are here.
I am having a problem and I really have no idea what the alternative is. There is some code I excluded for sake of making it extremely long.
s t and d is a butchered way of printing in the console, its butchered to pass through the filter.
void ProcessCommand() { string CurrentCommand;
s t and d : c o u t << ": "; s t and d : c i n >> CurrentCommand;
if (CurrentCommand == " L i s t U s e r s ( ) " ) { s t and d : c o u t << Users << end l; ProcessCommand(); //Reset it so that you can use another command. }
if (CurrentCommand == " L o g O u t ( ) ") { main (); //Reset the entire thing so that you can use a different user } }
int main() { //Set up stuff, to long to show in here.
//Bleh bleh bleh if there is a valid user and pass then:
ProcessCommand(); //Cool right? No. Because ProcessCommand is above it, it won't run. If I do put ProcessCommand below it, I won't be able to execute the main function for some reason.
}
|
|
|
| Report Abuse |
|
|
|
| 18 Jan 2017 07:37 PM |
Try forward declaring it by putting 'void ProcessCommand();' above your main segment.
Then define the function after the main segment. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 18 Jan 2017 07:39 PM |
Ah first post of the day I get ninja'd
|
|
|
| Report Abuse |
|
|
|
| 18 Jan 2017 07:40 PM |
This is actually pretty easy to understand if you look at it. I just have a function called "ProcessCommand" that takes in user input and executes an action based on what it is.
Everytime a command is called, (unless its ":LogOut()" ) then the function "ProcessCommand()" is called again so you can type another command in.
When you use :LogOut() its supposed to restart the entire thing and make you put in your username and pass. |
|
|
| Report Abuse |
|
|
| |
|
|
| 18 Jan 2017 07:42 PM |
w0t in tarnation is a forward declaration? I literally can't find it on the internet. I don't need you to incorporate it into my code, but just like show me a simple example. |
|
|
| Report Abuse |
|
|
|
| 18 Jan 2017 07:44 PM |
| #################################################################################################### |
|
|
| Report Abuse |
|
|
|
| 18 Jan 2017 07:45 PM |
http://www.
learncpp. com/cpp-tutorial/ 17-forward-declarations/
one google search: "forward declarations c++"
#code self = nil |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 18 Jan 2017 07:45 PM |
This is probably why you were coldly received in stack overflow. Googling: c plus plus forward declaration
yields a plethora of results |
|
|
| Report Abuse |
|
|
|
| 18 Jan 2017 07:47 PM |
^ Precisely, but I thought maybe they would shunn me if I used a language other than that of scripting here.
I started using this yesterday. .-. |
|
|
| Report Abuse |
|
|
|
| 18 Jan 2017 07:51 PM |
My eyes have been opened unto heaps of new information. Thank you for sharing that website.
I feel as the world of C++ consumes me, develops me, becomes me. Bye bye lua, lmao. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
Froast
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 3134 |
|
| |
|
|
| 18 Jan 2017 07:56 PM |
"I feel as the world of C++ consumes me, develops me, becomes me." u ok
|
|
|
| Report Abuse |
|
|
|
| 18 Jan 2017 07:58 PM |
| ^ idek, btw I figured it out, you guys are heaps of help. |
|
|
| Report Abuse |
|
|
|
| 18 Jan 2017 08:00 PM |
| For all those wondering, the reason I am so stupid with this is because I figured out how to make a "Hello World" file a little more than 12 hours ago. |
|
|
| Report Abuse |
|
|
nox7
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 27467 |
|
|
| 18 Jan 2017 08:01 PM |
| Welcome to the big world of programming. The amount of rules will be overwhelming. Enjoy Dante's Inferno. |
|
|
| Report Abuse |
|
|
|
| 18 Jan 2017 08:20 PM |
| Learning lua has really been a big help so far. |
|
|
| Report Abuse |
|
|