I'm glad you said you forget the function ptr syntax. I've been programming games for 20 years in c++ and still forget it aswell :). At least lambdas are more intuitive.
@@md2perpe If you understand how names in function pointers work, nothing. But if you are trying to write a function that returns a function pointer without using type aliases, then it ends up something like: void(*return_fun_ptr(int))(); This is a function named return_fun_ptr that takes a single int parameter that returns a pointer to a function that takes no parameters and returns void.
For me it's always been interesting that some CS people find pointers difficult. I came to C++ from electrical engineering, so bottom up, and just intuitively map the numbers to memory locations (ram,rom or device). (Sometimes a bit too much, as virtual memory mapping, addressa translations, caching etc sometimes confuses me. )
In the mid of the 1980's I learned Z80 assembly. The Z80 processor has a 16-bit register HL which can be used to refer to content at some location in memory. Some year after that I learned some Pascal from a book and there was a chapter about pointers. It was confusing to me, and I didn't understand it. Later I learned C and then it hit me: pointers are just memory addresses; it's just like (HL) in Z80 assembly.
I don't like the last part of the description "A pointer is a variable that stores the memory address of a specific object type". The object type is not really part of the pointer; it's rather information to the compiler (and to the programmer) what kind of data is found at that address so that one can easily access for example parts of a structure.
I don't think its the right way to teach pointers, same as 30 years ago. It's better to introduce ownership at the very first stage, for "modern" learners who's new to c++.
Thank you, Mike. This is a masterclass presentation on raw pointers. Thanks again
Glad it was helpful!
Probably one of the best explanations of pointers. Nice and simple, step by step.
Glad you think so! Thank you.
Thank you, Mike. Got a handle on function pointers now. Cheers!
Cheers!
great talk! to sum it up, with great power comes great responsibility!
thanks mike
Great Presentation, thank you for this Mike Shah.
Glad you enjoyed it!
Great Talk, probably one of the few talks that I listened to fully ! :)
Glad you enjoyed it!
I'm glad you said you forget the function ptr syntax. I've been programming games for 20 years in c++ and still forget it aswell :). At least lambdas are more intuitive.
I don't think function pointer syntax is too hard to understand; functions returning function pointers on the other hand...
@@alexandernyberg8668 What's difficult with that?
@@alexandernyberg8668 That's why you typedef/using it. That way all you have to do is just use the type alias and not worry about the weirdness.
@@md2perpe If you understand how names in function pointers work, nothing. But if you are trying to write a function that returns a function pointer without using type aliases, then it ends up something like:
void(*return_fun_ptr(int))();
This is a function named return_fun_ptr that takes a single int parameter that returns a pointer to a function that takes no parameters and returns void.
Good Sound! Always great to not have reverb ob everything
For me it's always been interesting that some CS people find pointers difficult. I came to C++ from electrical engineering, so bottom up, and just intuitively map the numbers to memory locations (ram,rom or device). (Sometimes a bit too much, as virtual memory mapping, addressa translations, caching etc sometimes confuses me. )
In the mid of the 1980's I learned Z80 assembly. The Z80 processor has a 16-bit register HL which can be used to refer to content at some location in memory. Some year after that I learned some Pascal from a book and there was a chapter about pointers. It was confusing to me, and I didn't understand it. Later I learned C and then it hit me: pointers are just memory addresses; it's just like (HL) in Z80 assembly.
@26.06, memory representation is wrong for f due to alignment, float value will be aligned on 4 bytes
Wonderful presentation. Thanks a lot.
I don't like the last part of the description "A pointer is a variable that stores the memory address of a specific object type". The object type is not really part of the pointer; it's rather information to the compiler (and to the programmer) what kind of data is found at that address so that one can easily access for example parts of a structure.
Now let's try to get my coworker watch this
code font size too small to read.
I don't think its the right way to teach pointers, same as 30 years ago. It's better to introduce ownership at the very first stage, for "modern" learners who's new to c++.
黃暐瀚你怎么开始搞C++了?