This is a quite nooby question, but is there any way to have the program control go sone two paths at once? For example: if my program has two functions, one that does some simple calculation that requires nothing from outside it to set the variables and another that displays text for the user to read then enter something. Is there any way to have both run at the same time?
1 2 3 4 5 6 7 8 9 10 11 12
simpleFnc()
{int a = 1;
int b = 2 ;
int c = a+b ;
}
complexFnc()
string secrets ;
{cout << "Enter your secrets to get magic powers: " ;
cin >> secrets ;
//blah blah blah
}
There is no connection of simplefnc to anywhere else in the program so is there any way to get it to run at the same time the other function is running?
Your question isnt nooby at all, trust me!
I believe that you may want to look at multithreading, google will possibly extend your knowledge on that.
Multithreading allows you to run two or more pieces of code at once, its really good for multicore systems ( which are reasonably common these days ) for increases in performance.
Not to mention how amazingly complex things become once you start to modify program state in more than one place at once. Unless you're very careful and disciplined (or you figure out how to write self-locking objects), it's not very difficult to bury yourself in bugs that are extremely hard to reproduce, find, and fix.