| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: c++ help |
From: "Paul Ranson"
The 'OnPlay3' function is called every time you press the button it's
mapped to. All the MFC stuff is happening on a single thread so you can
safely call
'srand' elsewhere and not need to again.
The library random number generator has its own private state that cares
little for your classes and functions, but it gets a new copy for each
thread. Your program is single threaded, so no problem.
Paul
"Geo." wrote in message
news:41b4c3d2$3{at}w3.nls.net...
> "John Beckett" wrote in message
> news:t2c7r0d4tmjul0a807paa26t2muv5bf6e3{at}4ax.com...
>
>> In the above, "static" means that the variable fDoneInit
retains its
>> value between calls to the function. The result is that srand will
>> only be called once, the first time OnPlay3 is entered.
>>
>> If more than one thread called OnPlay3, the above would not be
>> adequate (each thread has to call srand).
>
> As I understand it, in an MFC app when OnPlay3 is called it's created,
> when
> it exits it's destroyed so wouldn't you need to initialize the random
> generator each time it's created?
>
> Geo.
>
>
--- BBBS/NT v4.01 Flag-5
* Origin: Barktopia BBS Site http://HarborWebs.com:8081 (1:379/45)SEEN-BY: 633/267 270 5030/786 @PATH: 379/45 1 396/45 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.