You will never ask again about pointers after watching this video!

preview_player
Показать описание
In this video, I will teach you all you need to know about pointers in C++.
This video is aimed both at beginner and advanced programmers 💪!

Beginner: 0:56
Intermediate: 5:54
Advanced: 10:46

#cpp #programming #learncpp #gamedev

Also, check out how I handle memory management in C++! 💪:

Join my Discord 🤖:

My Steam Game: Midnight Arrow 🎮:

Join this channel if you want to support me 😻:

Check out My Minecraft Clone 🌳:

Full C++ Game Guide 🕹️:

Music:
Evan King - Booty Shake Robot
Evan King - Invisible Walls
Minecraft soundtrack: C418 - Aria Math
Рекомендации по теме
Комментарии
Автор

Your teaching style is batter than most c++ YouTubers for beginners.
It is mostly accurate.
This is what I seen that needed a bit of correction:


Well technically arrays are not pointers and if you use them like pointers they decay
So don't say that an array is a pointer .
The size of it is not normally the size of pointer .
They can be referenced like :
T (&ref)[N]

And this can not be a pointer reference so they are not the same.
Additionaly :
When you make a function with array arguments it is a pointer to the elements.
unless the arguments is a reference .
You can actually see this in msvc:
auto p="";
auto&&a="";

The types are:
const char *,
const char(&)[1]

and some parts about void* ers can led to undefined behavior if you use the wrong type.
And Additionaly you may use new and delete on their own but the catch is that your code is not exception safe .
make sure that at least the delete is in some kind of destructor to make it safer .
In fact you can make a custom( template ) class to hold a lambda and run that on destruction .
This will be handy I promise.

mahdijoharian
Автор

Beginner: 0:56
Intermediate: 5:54
Advanced: 10:46

hexa
Автор

Thanks for the video! This is a great video for an introduction to pointers!

I would like to add something to it though, like best practices, especially for beginners. Here's my take on it:
1. First of all never use *pointers*
2. If you need a dynamic memory, use *std::unique_ptr* instead for single ownership
3. In need of shared ownership? then look around your code, you probably structure your program badly
4. You absolutely need a shared ownership? use *std::shared_ptr* then
5. If you need a view to a memory/resource that you don't own, use a *reference* (borrowing)
6. If you need a view to a contiguous area of memory that you don't own, use *std::span* (*std::string_view* if it's a string)
7. Only if all the above not apply then you are probably okay using a *pointer*

Most of the time you want to use number 5 since dynamic memory allocation is not that common (always use the stack not the heap unless you need to).

Maiuna-ycuk
Автор

8:08 i always got confused at arrow operator now i understood it thanks for this video😊.

satyamraj
Автор

Learned a thing or two! Thank you for making this :D

LBCreateSpace
Автор

Simple way to abstract pointers is all they are literal pointers, you’re pointing to a value. Say if I’m pointing at a cat, the pointer isn’t the cat but my finger itself.

joshuacox
Автор

When you know how variables work, you know how pointers work. Don't be too afraid of pointers.

FD
Автор

Let's goo! Next make a tutorial video about making an multiplayer c++ game, pretty please?

washynator
Автор

Hey man, just asking whether you ever thought of making a video series teaching opengl, i really like the way you teach and think you're the perfect guy for this job

ali_gd_
Автор

make a video on memory allocation and smart pointers

draken
Автор

Thank you so much, super informative!

tsarman
Автор

So one of my university courses this semester actually requires me to make a text-based game in c++. This is actually so useful

not_vinkami
Автор

nice, very cool
Edit: i want the smart pointer video!

rikkoo
Автор

Great video, and i would love to see a tutorial on memory allocation : )

ChikenGaming_Offical
Автор

How come you don’t use smart pointers?

QWin-iryq
Автор

So i have a one question about pointers and references

when should i use a pointers to pass some data to a function and when should i use references?

void fun(int* ptr)

void fun1(int& ref)
This is confusing because they are very similar besides some sytax sugar.

viper
Автор

its ok,
but you def. should explain the syntax (very shortly),
before beginning the intermediate explanation.

I know the syntax, just saw that you already used syntax in your pics before explaining it.

Andy_B.
Автор

"I don't use smart pointer", that must have triggered a lot of C++ developers.

Brad_Script
Автор

I still don't get why people prefer using pointers when they do a bit of object-oriented... Maybe you'll tell us a bit more about this in your video about memory allocation 👍 I don't think I learnt something in this video, but it was explained very well, so congrats for "popularizing" this quite advanced concept, especially with these great metaphors!

FuIbion
Автор

I came here expecting some beginner stuff. Although i knew all of these, it really was an in-depth video about pointers. Specially things like funtion pointers that most beginners don't even know exist.
Another question that beginners ask is why arrays start from index 0, this could easily be added to when you talk about pointer arithmetic while accessing the array.
Overall a great video and something I'd recommend to people already familiar with the language incase they want to refresh their memory.

Dazed_