My question is a bit hard to explain if you haven't seen the code, so I'll jump right in. The code is not my actual code but a dumbed down version so it is easier to understand straight away.
class object {public: string m_greet; void greet()};
void object::greet(){m_greet = "Hello!"; Sleep(1000);}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
int main()
{
object obj1;
object obj2;
object obj3;
start:
system("cls");
cout << "obj1 says: " << obj1.m_greet;
cout << "\nobj2 says: " << obj2.m_greet;
cout << "\nobj3 says: " << obj3.m_greet
obj2.greet();
///goto start; (position b)
obj1.greet();
// (position c)
obj3.greet();
goto start; // (position a)
}
|
So in the example I am trying to make the objects introduce themselves out of order. Unfortunately if i choose to go to start at position a, it will introduce all the objects at the same time (sleep function will have no effect because the page does not refresh until all have gone through greet()) . And if i choose to go to start at position b, it will never introduce obj1 or obj3 as it will continuosly loop.
My question is, how can I make it so it introduces them individually, but continually refreshes the page? (without repeating the system("cls") etc.
My make-do answer would be to add a counter and add an if statement at position b and c, but it's hurting my brain to consider a few other things that would interfere in my real code