General Lecture/Section02 problem :/

Hi There
I’, having a general problem with the lecture, so far on Section 02.

The problem is that so far I understand everything Ben tells us, every line of code he shows seems logical when he explains and so on…

My only problem is, that whenever he wants me to figure something out myself (Like in Lecture 34 - when he tells us to replace WORD_LENGTH (about 3:50 in the video)) - I have absolutely no idea what so ever on where to start. No idea as to what would be smart to do (and the fact that he many times say that it is quite simple bothers me. If it is simple, why can’t I figure it out?)

Anyways, do you think this “problem” will “go away” as wI get more familiar with coding or do you have any idea as to what I could do?

Hello,

Not to worries, I felt the same way :slight_smile: I am very new at this as well.

I believe, he does that on purpose, because programming requires one to think of solutions to problems and since there is not “standard” way to do things, there is a syntax but there is no established ways of doing many things and it comes up to us to figure out how to approach it or how to solve it. There is a reason why Projects are parts of “Solutions”.

Therefore, we have to get in to the minding of identifying problems to solve every step of the way.

So my advice…do not be afraid to experiment.

He hinted that we need to put Word_length somewhere, think about what the “constexpr” was there for, repeat the part he introduced it in the video what was it linked with, I’ll give you a hint. The “X”…so the problem is how to replace the “X” with World_Length’s value, use the CTRL-F5, do a small change, then run the program does it work is it as you want it? Make changes Run it again. Use what we have learned so far, the learning is procedural.

If you really have no idea after several tries and you keep getting errors. Advance to the solution in the Lecture, it is fine, it is very early in the course and especially if you are new to programming it is more than fine. :slight_smile:

You would have pushed your neurons enough and you will say “Doh!” or “Aha!” but that fact will make you better for next time and so on and yes in time it will be easier and you will be much more comfortable.

Rest assured it happens to all of us :slight_smile:

Hope this helps,

By the way, besides the Book referenced in the class “Code Complete”, I got myself a couple more books which are helpful. At this point I am advancing the Class slower than others because I am reading the books a bit trying out stuff they suggest to get a better grasp of some notions and concepts in introduced this class.

I suspect later on we will be focusing more on Unreal than actually learning C++ so I felt the need for some more in depth information, which again I suspect is a bit beyond the scope of this class and since I like C++ so far and I absorb it well.

One of the books I got is this:

I am learning conceptually that C++ is not a procedural language, I used that term above to my first reply for qualifying the learning, because we learn sequentially step by step adding more complexity. But the C++ language itself is not a procedural Language, it is more heuristic in its nature and I understood that through the books.

The Other book is:

There is also a third edition but focuses on C++ 14 standard.

So sharing in case that helps, they help me in this class.

Cheers!

All beginning programmers face an issue like this when they first lay their eyes on some lines of code, it may read logically, but our brains just haven’t been trained on how to write it logically. I have a lot of friends in the software development business, and even they struggle with this from time to time. The best thing you can do to train yourself in writing code is to study the code you have written and mentally group it into section of what it does, Pseudocode is awesome for this. Just take some time to study the code. In some cases it’s just best to walk away from the code for a bit and come back to it the next day. With in time things will get easier so don’t worry about it too much.

If you’re buying C++ books for beginners, go for Bjarne Stroustrup’s Programming: Principles and Practice Using C++ (2nd Edition). I believe it goes very well with this course, at least I have found lots of value in it myself. The Prata Primer is okay, but I don’t think it’s great - by the 6th edition, it really shows that it hasn’t been properly edited for a couple of iterations (paperback version). I’d rather recommend the Stan Lippman Primer, which also has more fun example code to go along.

Also, check out the SO book guide, it has a bunch of great recommendations!

Appreciate the Feedback, I was about confused with the C++ Primer from Lippman and Prata, I thought it as the same Book and the Primer Plus had some extras.

I got the Books mainly for getting understanding of various notions as each one explains it slightly differently. My main guide is of course this course here, and the very excellent Book that is suggests Code Complete. Which I like so far lots.

By the way I did see Bjarne Stroustrup’s Programming: Principles and Practice Using C++ (2nd Edition), and he is the one that Found C++ to begin with, it was a bit more pricey thought and there were offers on the others and I had points to spend. But it is definitely on my “to get” list.

I wonder what would you think about Michael Dawson’s “Beginning C++ through Gaming Programming”?

Don’t want to overdo it either. :slight_smile: Between this and that explanation and practice it should be enough.

Thanks though.

1 Like

“Beginning C++ through Gaming Programming” is okay, definitely a a more fun way of learning concepts. However I would suggest C++ Primer 5th edition (not primer plus) and “A Tour of C++” from Bjarne, it’s essentially a condensed version of his “Principles and Practice Using C++” which will be a lighter read and then Primer for a more in-depth read.

Haha, I did exactly the same, which is why I ended up with both the Lippman Primer and the Prata Primer Plus :slight_smile: I haven’t read the Dawson book myself, so I can’t comment on it - except that it seems to get decent reviews on amazon, and it is fairly cheap for a book on C++, so I might end up picking it up myself. Thanks for the tip!

1 Like

Can someone please explain why we use constexpr? What does it do?:slight_smile:

constexpr, the const part of that is short for constant. Something that Should not ever change once the game is running. You are using it as part of the variable declaration and applying a value to that variable. Before compiling the code, you can edit that variable manually, but nothing within the game should be able to change the variable’s value. For example, if you change the length of the words in the library to 10, you can update the library words, then change the word_length variable to match the new word length.

Game is now broken, compiles fine but I get the following error when entering any guess:
FYI This is using the exact copy commit as per :: https://github.com/UnrealCourse/02_BullCowGame/tree/69fb2728d0c8fdab1fc921169129f7fe58d97e58

ERROR: Expression: string subscript out of range

When i comment out the below section things work, so far even putting a break point in has not helped. I am at a loss as to what is exactly happening here? Is it out of bounds? I could nail it to this line –

if (Guess[GChar] == MyHiddenWord[MHWChar])

when you call that i get the error…

Image of Error received

for (int32 MHWChar = 0; MHWChar < HiddenWordLength; MHWChar++) { // compare letters against the hidden word for (int32 GChar = 0; GChar < HiddenWordLength; GChar++) { // if they match then if (Guess[GChar] == MyHiddenWord[MHWChar]) { if (MHWChar == GChar) { // if they're in the same place BullCowCount.Bulls++; // increment bulls } else { BullCowCount.Cows++; // must be a cow } } } }

EDIT: And the weird bit is I had this working until we fixed the error in Debugging 101

I’ve replied to your GitHub issue, but I’ll post it here too since I ran into the same problem.

I changed a couple of things to make it work again - first of all initialised HiddenWordLength to 0 before assigning MyHiddenWord.length() to it:

int32 HiddenWordLength = 0;
HiddenWordLength = MyHiddenWord.length();

Also changed the first if statement to be:
if (Guess[i] == MyHiddenWord[j])
because otherwise it counted everything twice.

I’ve posted the full code on GitHub, so hopefully it will help you :smile:.

fixed as per my separate thread as well :wink:

Privacy & Terms