Implicit Conversion and the Explicit Keyword in C++

preview_player
Показать описание


Gear I use:
-----------------

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

22 years old and teaching like a war veteran.
Glad my parents doesn't know you, so they can't compare =P

brunooliveirasoares
Автор

This has changed in the passing years, you now have to do Entity a = std::string("Cherno");

This is because of the same explanation at 3:46

saladgaming
Автор

We should make a tree for all the dependencies between the videos :D biggest tree ever

Cynokine
Автор

I have gone through a lot of channels on YouTube for over-viewing C++ related content . Hands down, your channel is the most concise and easy to grasp one. I very much appreciate your rigor and desire to share knowledge. Kindly keep up the good work.

kshitijkumar
Автор

I am glad that you are continuously doing tutorials in C++. Thanks for making them.

pinklady
Автор

My biggest take away from this is you were 22 and had the experience of a 32.

hokhyt
Автор

I'm 14 years old and this stuff will differently help me in my future career.

jamalnavarro
Автор

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

srisairayapudi
Автор

waving my arms around thank God you realized that
love these tutorials great job and thank you

小龙的梦
Автор

i tried a lot but i could not understand .
why Entity e ="cherno"; works when printentity("cherno");
In the Entity e ="cherno"; also cherno is a const char arrray[7] so it must be first converted into std:: string and then into entity.two implicit conversions are needed.
but how it works???


i could see in comments that some say Entity e ="cherno"; is simply Entity e =Entity("cherno"); and only one implicit conversion is needed for std:: string.
if that is the case if i make the constructor as explicit .
then Entity e=22; is simply Entity e=Entity(22); must work but it fails....

monishkumardurairaj
Автор

this channel is a masterpiece, this guy is a talented teacher and programmer, thanks for this in deep series free .

code-island
Автор

links here, links there, links fucking everywhere

vaecore
Автор

"There will be a link in the descpription" - will it, though? ;)

kanskejonasidag
Автор

Great videos you did! Very condensed and right to the point.

reaper
Автор

Thank you. This is the best video I've seen on this subject.

ak-geqc
Автор

I'm currently digging my way out of a series of wrapper containers for a school project, whose iterators wrap other iterators that wrap other data structures, ultimately with as many as six levels of indirection and substantial use of implicit conversions, complete with conversion overloads, to const the damned things. At times I'm just genuinely amazed the thing compiles and runs at all and that I actually coded it myself. xD

mikicerise
Автор

How are you only 22 and have so much experience? I'm 24, and yes, quite jelly.

Anyway, keep it up!

ohaRega
Автор

1:43 you are now 28 years old as from 30/11/2023, time flys lol

michaelswahla
Автор

I finally get what the explict word before constuctor means, thank you

TommySnow-ujzn
Автор

5:50 if we have

explicit Entity(const std::string& name)
: m_Name(name), m_Age(-1) { }

then

PrintEntity(Entity("Cherno"))

should fail, right? Because in this case, "Cherno" is `const char[ ]` not `std::string`, right?

So, with the `explicit` keyword, conversion from `const char[ ]` to `std::string` should not happen, and eventually, the compiler should give an error, right?
Because with the `explicit` keyword, `Entity` constructor either accepts `int` or `std::string` not `const char[ ]`. So, is the right way not `Entity("Cherno")`, correct?

However, here, `Entity("Cherno")` is working without any error! Why?

milan_shah