Комментарии:
Hi Cherno, when i use Entity a = "Cherno" it shows error "no visible conversion". so i change to Entity a = std:string("Cherno") it works. why in your video , Entity a = "Cherno" works.
ОтветитьI finally get what the explict word before constuctor means, thank you
ОтветитьGreat videos you did! Very condensed and right to the point.
ОтветитьDoes that keyword work for converting two different entities to each other?
Like a Cartestan point to a polar point, or vice versa.
I'd like to ask a question about the statement " Entity a = "Cherno" ". "Cherno" needs to be converted to string, and string needs another conversion to get Entity, so it totally needs two conversions to get Entity object from "Cherno", which is unacceptable in C++. But why this statement in the video can be compiled and run successfully? I've tried it on Visual Studio 2022, and the compiler does report an error. Actually, I have to rewrite the statement as " Entity a = std::string("Cherno") " to make it work.
Ответить22 back then and you knew this much, wtf, you have a laptop in the womb or something, this makes me feel incredibly being in my 30s and only learning it now 😂
ОтветитьWhy did you slap me twice at the beginning🙁
ОтветитьSo, when executing PrintEntity(22), does it create an object? Or is the point that we can access the internals this way?
ОтветитьYo I always thought you were much older and I was like damn I can catch up to you but how the hell do you know so much at 22??? Super impressive. Cant believe you're doing insane at 27 now
ОтветитьPersonal Notes:
- Implicit conversion: for an object which has constructor Entity(int age), you can instantiate an object by saying Entity e = 44, it is allowable, c++ does the conversion itself
- explicit keyword prevents implicit conversion. For example, for a constructor explicit Entity(int age), you cannot create object by saying Entity age = 44
you're a god of teaching C++
ОтветитьThank you. This is the best video I've seen on this subject.
Ответитьrust developers: >:(
ОтветитьWho knows what standard is it?
C++11?
Wait..
Are you actually 22?
20 year old me :{ Imposter syndrome kicks in...
Prevent unwanted implicit conversions with explcit keyword.
ОтветитьWow. This is crazy, man. I never seen anyone do Entity b = 22. Where have you got all this from?
Ответить