Modern C++ (data types, references)

  Рет қаралды 16,574

CopperSpice

CopperSpice

Күн бұрын

Пікірлер: 32
@4n0nym0u5
@4n0nym0u5 Жыл бұрын
This video is like a needle in a haystack. So valuable. Thank you so much!
@DanielMojoli
@DanielMojoli 11 ай бұрын
Eloquent and beautifully thought. Every C++ novice should watch this.
@ekandrot
@ekandrot 7 жыл бұрын
For the slide "Method pointer data type" at 12:16, wouldn't the calling convention be "bool data = (foo.*myMethod)(row, col);" because you have a local foo? (I tested it to verify)
@CopperSpice
@CopperSpice 7 жыл бұрын
Great catch! Thanks for the comment. You are correct. In our production code, we rarely call a method pointer on an object so we overlooked this point.
@tiennguyenviet4837
@tiennguyenviet4837 6 жыл бұрын
Can you explain for me 7:52 "pass by reference means only a reference to the data is pass and not the actual data"
@CopperSpice
@CopperSpice 6 жыл бұрын
Thanks for your question. In C++ there are two fundamental ways to pass data to a method or function. One is by value, and the other is by reference. Passing by value means the called function receives an exact copy of the original data. As a silly example, if the data is an orange and you pass by value the function will receive a copy of the orange. You can think of pass by reference as giving the called function a piece of paper indicating where the orange is. If the orange is passed by reference and the called function peels the orange, the caller will see the modification to the orange since no copy was made. There are tradeoffs to the decision of passing by value or by reference. The decision is typically based on whether modifications should be seen outside of the function, and how expensive it is to copy the data. I hope this helps. If you have other questions feel free to let us know.
@tiennguyenviet4837
@tiennguyenviet4837 6 жыл бұрын
thankyou so much. yesterday, i find answer for my issue on internet. I really thank for your help. it's helpful answer
@김진오-j3p
@김진오-j3p 5 жыл бұрын
Is there any documents or video that explain how Pointer and Reference are different in detail? (10:40) Is it related to the Const?
@jvsnyc
@jvsnyc 3 жыл бұрын
Sorry it is so late, but this video definitely goes over the very basic differences very thoroughly: kzbin.info/www/bejne/qKK5iJ1mlruGrsk The whole video is good, but your question is answered at 52:21.
@nexusclarum8000
@nexusclarum8000 7 жыл бұрын
This is a fantastic video. One thing I realized is that in my mind I always pronounced things oddly. While I always knew "char" is short for "character" I would still pronounce "char" in my head as in "charcoal" and "enum" which is short for "enumeration" as "e" and "num" together. Hmm... I wonder if I could use a method pointer to get around the problem I had before... I was mapping function pointers to strings in std::map in a method. But for it to work I had to make all the methods static and therefor none of the methods could modify non-static members.
@CopperSpice
@CopperSpice 7 жыл бұрын
Thank you so much for your feedback. We are happy to know you enjoyed the video and learned something. It sounds like you might have a question about using a method pointer. Please feel free to post a question about your code on our forum. Under CopperSpice we set up a topic which is labeled "KZbin Channel". forum.copperspice.com/
@Bob-zg2zf
@Bob-zg2zf 4 жыл бұрын
Lmao. I too have been saying "charrr"...
@konstantinossimatos3466
@konstantinossimatos3466 Ай бұрын
Let's take list, or hash or.... Is a list a data type or list is a data structure where you can save, retrieve... data types?
@CopperSpice
@CopperSpice Ай бұрын
Every object has a data type and a value. Containers like hash, vector, or list are Compound Data Types. The definition of a Compound Data Type is a type which is derived from other types. A data structure is normally implemented as a Compound Data Type. The operations a given type supports is not related to whether it is a primitive type, built in type, or a compound data type.
@罗登-j7n
@罗登-j7n 4 жыл бұрын
Where can I download the .ppt of .pdf files and the demo code you presented? I can not find them on the given website or download link. Is that avaiable? I just want to use it for personal study, thank you.
@CopperSpice
@CopperSpice 4 жыл бұрын
You can watch these videos as many times as you like and study them as you go. Experimenting with the samples is a great idea and it is good practice to type unfamiliar code. You may even want to close the video and try to type the sample from memory just to see how much you can remember.
@cpp1158
@cpp1158 3 жыл бұрын
Great stuff
@SandburgNounouRs
@SandburgNounouRs 6 жыл бұрын
After viewing this video, I have a pending question: Since you talk about that, may you write some of the features aloud by reference that are not by pointers?
@CopperSpice
@CopperSpice 6 жыл бұрын
I am not sure I understand your question. However, if you are asking "what can references do which pointers can not" one good example is the ability to extend the lifetime of a temporary object by binding it to a const or rvalue reference. This lifetime extension is not available for pointers.
@jvsnyc
@jvsnyc 3 жыл бұрын
Sorry it is so late, but this video definitely goes over the very basic differences very thoroughly: kzbin.info/www/bejne/qKK5iJ1mlruGrsk The whole video is good, but your question is answered at 52:21.
@aj-uo3uh
@aj-uo3uh Жыл бұрын
Why would you call a function pointer a datatype, its not data.
@CopperSpice
@CopperSpice Жыл бұрын
A "data type" refers to the contents which is stored in a given object. Every variable has two parts, a data type and a name. So "int counter" declares a variable named "counter" which stores data of type int. If you have "Widget (*ptr) ()" this declares a variable named "ptr" which stores a "pointer to a function". A "pointer to a function" is another name for a "function pointer".
@mage1over137
@mage1over137 4 жыл бұрын
I guess C++ didn't exist before C++98 since it's always been in C++ and was added in C++98.
@CopperSpice
@CopperSpice 4 жыл бұрын
The first ISO standard for C++ was released in 1998, however the language was first available in the mid 1980s. Having a standard for the language has its pros and cons. Take a look at our video about the ISO standard for more information: kzbin.info/www/bejne/qXnWZ3-Bps2Dl6s
@jvsnyc
@jvsnyc 3 жыл бұрын
Ha, I see that like myself, you used to call function objects functors, and have since ceased to do so. I also have stopped, because your later talks told me to.
@CopperSpice
@CopperSpice 3 жыл бұрын
Actually, we personally never used the term "functor" in our communication or work. This distinction was added to clarify that not all computer science terms apply to C++ and we should strive to be clear about all terminology.
@tetramaximum
@tetramaximum 7 жыл бұрын
Thank you very much for your videos, they are very very good, clean and short! I have found some typos though, which may confuse the newcomers. At 12:20 you use "foo->", but foo is not a pointer, it should be "foo." instead. Moreover, you did not take an address and call the pointer, which leads to the crash of course. Here is the short proof: coliru.stacked-crooked.com/a/9f7161b3145f66d6
@CopperSpice
@CopperSpice 7 жыл бұрын
Thanks for the comment! As you and Edward Kandrot both noticed, we had a typographical error on the slide. You are correct, it should have been "foo.*"
@bonbonpony
@bonbonpony 4 жыл бұрын
Quite complicated "Beginning" :q
@zishiwu7757
@zishiwu7757 4 жыл бұрын
As Joel Spolsky says, all abstractions are leaky and C++ exposes you to a lot more details than other languages with garbage collection (Java, Python, etc.) would.
@bonbonpony
@bonbonpony 4 жыл бұрын
@@zishiwu7757 I wasn't talking about C++ (which I know pretty well). I was talking about the style of this lecture.
@adrianomachado5629
@adrianomachado5629 4 жыл бұрын
cry udemy!
Modern C++ (value categories)
17:51
CopperSpice
Рет қаралды 13 М.
Arenas, strings and Scuffed Templates in C
12:28
VoxelRifts
Рет қаралды 103 М.
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН
Modern C++ (move semantics, perfect forwarding)
19:49
CopperSpice
Рет қаралды 22 М.
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 343 М.
C++ Super Optimization: 1000X Faster
15:33
Dave's Garage
Рет қаралды 334 М.
2 Years of C++ Programming
8:20
Zyger
Рет қаралды 318 М.
Multithreading in C++
16:28
CopperSpice
Рет қаралды 17 М.
Visualizing memory layout of Rust's data types
39:39
Sreekanth
Рет қаралды 29 М.
Type Traits
13:37
CopperSpice
Рет қаралды 14 М.
Constexpr Static Const
19:52
CopperSpice
Рет қаралды 7 М.
you will never ask about pointers again after watching this video
8:03
You Should Learn C++ (for hacking games)
6:11
cazz
Рет қаралды 468 М.
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН