This video is out of date?

As of 4.17, the TankPlayerController.cpp file won’t compile if anything other than #include "TankPlayerController.h" is the first header file included. This means that Ben’s build at 5:20 in this video will also fail to compile with the error:

Expected TankPlayerController.h to be first header included.

Additionally, the forward declaration video was a couple of lectures ago, and the next lecture doesn’t seem to talk about the issues raised in this video at all.

In regard to forward declarations, I still don’t really understand why we use them. I understand that it increases compile speed, but from what reading I’ve done around the subject, the general consensus seems to be to favour #includes over forward declarations. The Google C++ Style Guide explicitly advises against their use whenever possible, with the only benefits being a quicker compile time.

I understand that forward declarations are a feature of the C++ language, and as such, it’s an important learning exercise to be exposed to them in our code, however I feel that they’re introduced in the videoes, without really discussing any of the benefits and drawbacks (although there may be discussions on this in future lectures, I’m only up to this video so far!).

I absolutely love this course, and have been having a blast, but I feel the structure of the last few videoes has been a bit messy. I’d recommend moving this video to before the “Using Forward Declarations” lecture (I think it should be anyway?), removing the obsolete part from 3:54 onwards, and replacing it with an introductory discussion on forward declarations and why and when we would use them. I think that this would greatly increase the flow of the learning process, as well as allowing us to expand our knowledge of forward declaration, which I feel we are currently lacking.

2 Likes

@sampattuzzi

Have you seen the new lecture called “Include What You Use” it should cover these header topics. You may have taken the battle tank content before the lecture was added.

Hi Sam,

Thanks for getting back!

Yes, I’ve seen that video (Lecture 64 I believe?); I’ve actually done the whole course in version 4.17 so far so I’m getting pretty used to digging out the correct header files to include! I guess that the reason Ben’s build at 5:20 doesn’t work in v4.17 is probably because of the change to the IWYU architecture and the way this version handles header files? After going back through the video (and reviewing the "Include What You Use video), my original questions still remain:

  • Some of the content in this video doesn’t seem to be relevent to v4.17 onwards as you can no longer compile a .cpp file unless it’s header file is included as the first #include in the file - is this correct? If this is the case, it would be nice to have a note on screen (maybe around 5:20) saying that this doesn’t work in 4.17+, as it’s a little confusing.
  • Surely this video should be before Lecture 138; “Using Forward Declarations”? Ben states at the start of this video that we are “setting the stage for the next video about Forward Declarations”, but the next video isn’t about forward declarations as far as I can tell!
  • I understand what forward declarations are, and how they are implemented, but why are we using them? Ben mentioned that it prevents “weird strings of dependancy”, but what does that mean, and why does it matter? It seems like a very contentious subject on Stackoverflow, so I’m just curious as to how you’ve arrived at the decision to only #include header files in header files when inheriting from that class.

Thanks in advance, I really appreciate all the effort you guys put in to make these lectures, and I hope I’m not being too much of a pain!

What Ben means is that we can end up including header files we didn’t need because another header we include uses them. This can lead the cpp to bloat as you know and slow down compile times. As you say, the issue is contentious, we came down on one side of it for simplicity.

You are right that the reordering is odd in light of 4.17. I have made the note suggested.

You are absolutely right. The order of this lecture was very messed up in our system but I have fixed it throughout now.

Thanks so much Sam! I didn’t mean to be pedantic about forward declarations, but it really helps to know why the design choices were settled on, especially in areas such as this where there is no clear cut “best” way.

Often the case with programming.

1 Like

Privacy & Terms