C++/Game Tutorial 11: Static Variables And Pass By Reference!

preview_player
Показать описание
Today we briefly cover static variables and passing values by reference!

Рекомендации по теме
Комментарии
Автор

just a stellar programming teacher, you set everything so it leads to the next so we actually understand why we do something, not just that we do it. you give a thorough understanding of how why C++ is set up the way it is. instead of do this, to do this and don't worry about this type of teaching

mycollegeshirt
Автор

4 years of my under graduation and today I learn what static variables are. Thank you.

PranayKotapi
Автор

I feel bad I discovered this channel so late, your teaching style is really great. I'm not going to name any of the other multiple tutorials/channels I've looked at, but your teaching method is fantastic, you really make it fun. I'm going to direct newbies this way!

leerv.
Автор

I know quite a few things in C, but I've struggled many times figuring out what static specifier does, you made it very simple! I also like your tone, very friendly and easy to follow along. :)

paulocbbf
Автор

Was doing the TicTacToe challenge and was stuck for literally hours wondering why the changes to my Array weren't being reflected when I displayed it using cout, then I remembered this video...

Thanks again Ben for another very helpful video.

skeetlejuice
Автор

Your videos are incredible... Its good to have people like you in the world. With so much knowledge, and helping others. Thanks a lot. 

LuizHeringerCantor
Автор

Thank you so much. The way you teach is very very easy to understand. I used to be very scared of learning programming and now I feel more confident. Hope I will be good at it some day near.

nhatvule
Автор

Yo I came across your tutorial and so far this is the best c++ tutorial since it teach us c++ but also in terms of game developing. The best thing in this tutorial is you teach us c++ the 'fun way'. But I saw that your last video was 3 years ago ? Are you planning to update again?

khyle
Автор

I have a problem please Help!


In the game that i have made from your challenge video, The simulateBattle() function has the final number of humans and skeletons left.... Sooo... How can i get the final value of The creatures left in the battle if SimulateBttle() is a void???

tashadurrahman
Автор

Hi. This might seem like a stupid question but how do you get that zoomed code window to the right? It seems really helpful and I've searched far and wide on google for the the answer but can't find anything :/ .. And awesome series!

seriouslee
Автор

+3d834 "Since the random number changes only once per second" not entirely true. The initialization of the generator is the only call that relies on time, and ideally you only do this a single time. Every attack after that is going to be using a new random number, you don't have to re-seed with time ever single time you want a new number, just initially. Thats why its called "seed"

makinggameswithben
Автор

Do you have to create your functions at the end of the program? I think it would be easier to put your variables at the top so they're global and create the functions under them.

kevinkyle
Автор

But how is static gonna avoid the results keeping same if it's idea is to keep the variable same and NOT to declare it again???

Galluxi
Автор

So a static variable is basically a less secure const?

amlenk
Автор

Hi there Ben i have a question for you :)  Do you know of any good C++ books? (I know Java so i am not totaly new to coding)

a-
Автор

This is how I describe static: Only one of them exists even if you have 1000 instances of your class.

DJoppiesaus
Автор

May i know, why do we have to declare the functions before int main() and also after the main function ?

rohitvarmabhupathiraju
Автор

is using the & for the parameters like similar to using "this" in other languages? or am i thinking wrong?

K-Tech
Автор

So, I've built a more complex simulator than this and I'm having a really hard time splitting it into functions. There are so many variables that are out of scope to the point where everything will have to be a global variable anyways, or I'd have to make 100 functions to return all them. The "object-orientedness" is making my code worse, especially on such a small scale as this. I get that if you don't compartmentalize then your code isn't "reusable" but how often will I ever actually need to do that exact same thing again anyway that I didn't already plan for? I'll likely need to build a new function for it anyways. Anyway, just a bit frustrating trying to artificially cut things up...

bighugejake
Автор

Is there any sort of documentation commenting in C++?

Ian