Timeline for CLI Hangman game in C++
Current License: CC BY-SA 4.0
16 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 10, 2019 at 8:14 | comment | added | L. F. |
@d4rk4ng31 It’s called the “trailing return type” auto f() -> T is equivalent to T f()
|
|
Sep 10, 2019 at 7:32 | comment | added | kesarling |
One more thing. I have never seen this syntax. What does auto Hangman::guess() -> State do?
|
|
Sep 10, 2019 at 1:44 | comment | added | L. F. |
@d4rk4ng31I Yeah, it still works in C11 AFAIK, but please note that the notion of "register" doesn't exist in the C or C++ standards, so it exists merely as a recommendation to the implementation. The recommendation isn't always respected, anyway - the implementation is free to put a non-register variable in registers, and free to put a register variable outside registers.
|
|
Sep 9, 2019 at 16:17 | comment | added | kesarling | Oh!! But does it work at least in C (still) ? | |
Sep 9, 2019 at 16:03 | comment | added | pacmaninbw♦ | Alphabetizing includes may not work in all cases. | |
Sep 9, 2019 at 16:02 | comment | added | pacmaninbw♦ | @d4rk4ng31 Good optimizing compilers will do a better job of allocating registers than the author (supposedly). Good optimizing compilers may modify the algorithm as well. | |
Sep 7, 2019 at 9:37 | history | edited | L. F. | CC BY-SA 4.0 |
added 3381 characters in body
|
Sep 7, 2019 at 9:27 | comment | added | L. F. |
@d4rk4ng31 register is specified to have no meaning since C++11, and "poisoned" since C++17 (i.e., using it is ill-formed)
|
|
Sep 7, 2019 at 9:26 | comment | added | kesarling | Let us continue this discussion in chat. | |
Sep 7, 2019 at 9:25 | comment | added | L. F. |
@d4rk4ng31 Yeah, <random> is a big one. You need to construct an engine first (e.g., mt19937) and then use a uniform int distribution to generate an index from, say, 0 to 25.
|
|
Sep 7, 2019 at 9:24 | comment | added | kesarling |
Also, is there any specific reason for compiler to ignore register keyword?
|
|
Sep 7, 2019 at 9:15 | comment | added | L. F. |
@d4rk4ng31 As I said before, rand() is a low-quality RNG and should not be used. C++11 offers the <random> header which contains high-quality RNG.
|
|
Sep 7, 2019 at 9:09 | comment | added | L. F. | @d4rk4ng31 You are welcome. Essentially, the game needs to keep track of some states (the word, the current guessed letters, lives left), so it is advised to use a class to encapsulate them. | |
Sep 7, 2019 at 9:01 | vote | accept | kesarling | ||
Sep 7, 2019 at 9:01 | vote | accept | kesarling | ||
Sep 7, 2019 at 9:01 | |||||
Sep 7, 2019 at 8:42 | history | answered | L. F. | CC BY-SA 4.0 |