Casting in C++

Patreon ► / thecherno
Twitter ► / thecherno
Instagram ► / thecherno
Discord ► thecherno.com/discord
Series Playlist ► thecherno.com/cpp
Thank you to the following Patreon supporters:
- Dominic Pace
- Kevin Gregory Agwaze
- Sébastien Bervoets
- Tobias Humig
- Peter Siegmund
- Kerem Demirer
Gear I use:
-----------------
BEST laptop for programming! ► geni.us/pakTES
My FAVOURITE keyboard for programming! ► geni.us/zNhB
FAVOURITE monitors for programming! ► geni.us/Ig6KBq
MAIN Camera ► geni.us/t6xyDRO
MAIN Lens ► geni.us/xGoDWT
Second Camera ► geni.us/CYUQ
Microphone ► geni.us/wqO6g7K

Пікірлер: 177

  • @naoufal450
    @naoufal4505 жыл бұрын

    After watching accidentally a video of yours, I found you an awesome teacher and I've completed the whole series in a matter of days, never gets boring. You really motivated me to seriously learn this language (I did know most basic things but was lazy and stopped), I hope you continue doing videos, trust me it's going to be a very valuable library.

  • @ianpan0102

    @ianpan0102

    3 жыл бұрын

    Can't agree more!

  • @yaseenkhattak1845

    @yaseenkhattak1845

    2 жыл бұрын

    valuable library indeed !

  • @jaesiraki84
    @jaesiraki843 жыл бұрын

    Such a modest energy and I can actually understand what you're saying. Thanks!

  • @MaySmithereen

    @MaySmithereen

    2 жыл бұрын

    Some people explain in a very gate-keeper type of way :( Really glad people like him exist!

  • @sonulohani
    @sonulohani5 жыл бұрын

    You explain very well. And youre the only one who doesn't use mac book.

  • @groberti

    @groberti

    5 жыл бұрын

    He is the only C++ programmer who does not use a mac? It should not matter anyway :)

  • @lukedk4614

    @lukedk4614

    3 жыл бұрын

    @@groberti It does matter once you get into platform specific implementations. Obviously someone in a mac won't use things like the Win32 or DirectX / Direct3D (well not officially anyways). But yeah, for this topic specifically it doesn't matter.

  • @groberti

    @groberti

    3 жыл бұрын

    @@lukedk4614 Well, obviously. Or you could use a cross-platform framework (like OpenGL) and then it does not matter as much. The op is not explicit enough btw, are most other people who teach C++ use Mac or do programmers in general? I do think that the Mac is the most convenient platform if you are developing "platform independent" things or if you're developing for the Mac. Or even if you are developing for multiple platforms, but then you'll need another computer with Windows / Linux as well anyway

  • @smileynetsmileynet7922

    @smileynetsmileynet7922

    3 жыл бұрын

    @@groberti He's not the only one that doesn’t use a MacBook. Lots of people dont use them. For me, they are simply too expensive. But I use both Windows and Linux all the time. Now, for the bleeding edge, Linux is the one that gets features first for my languages, such as PNF.

  • @FedJimSmith

    @FedJimSmith

    Жыл бұрын

    @@groberti he's a game developer and the game he develops run on windows not mac or linux, so obviously he will use Visual Studio on Windows

  • @leixun
    @leixun4 жыл бұрын

    *My takeaways:* 1. Implicit and explicit casting - C style 1:53 2. Static cast - C++ style 4:15 3. Why we want to use C++ style cast 4:44 4. Dynamic cast - C++style 8:44

  • @tickletickle8561

    @tickletickle8561

    2 жыл бұрын

    lovely!

  • @budgetarms

    @budgetarms

    Жыл бұрын

    no const_cast?

  • @Anthony-be1ee

    @Anthony-be1ee

    11 ай бұрын

    5. Const cast - C++ style 12:03 6. Reinterpret cast - C++ style 12:24

  • @KostasOreopoulos
    @KostasOreopoulos5 жыл бұрын

    static_cast also helps to avoid removing constantness that can be easily done through c-style casting

  • @hammielover225

    @hammielover225

    3 жыл бұрын

    @Ameer Leonel BOT

  • @hammielover225

    @hammielover225

    3 жыл бұрын

    @Jon Anderson bot?

  • @fppt1555

    @fppt1555

    3 жыл бұрын

    @@hammielover225 Yes these always come in pairs, one claims to hack his gf's/sister's Instagram, and the other says he'll try it out.

  • @hammielover225

    @hammielover225

    3 жыл бұрын

    @@fppt1555 I know that

  • @itsmaxim01
    @itsmaxim016 ай бұрын

    another drawback of (C)style casts is that they will attempt every cast type until one works, meaning the result won’t necessarily be what you expect

  • @xonxt
    @xonxt5 жыл бұрын

    I've read somewhere, that it's actually faster and more efficient to use the C++-style casting, because if you use the "old style" casting, the modern compiler will try to attempt every c++-style casting in turn (const -> static -> reinterpret) and return the result of the first successful cast. But if you use one of them explicitly yourself, you just do it directly, without extra steps.

  • @theshermantanker7043

    @theshermantanker7043

    Жыл бұрын

    It's faster at compile time, not when actually running

  • @ataladin87

    @ataladin87

    Жыл бұрын

    @@theshermantanker7043 difference???

  • @oreoisacat6297

    @oreoisacat6297

    10 ай бұрын

    @@ataladin87 it will compile faster but when you run it, c style would be faster.

  • @work9167
    @work91672 жыл бұрын

    I am happy you make these videos. Because I study Computer Science in my university and it really helps me understand information which I didn't get in my class

  • @chinmaydas4053
    @chinmaydas40535 жыл бұрын

    Sir, now We need more advanced c++ series from a great guy like you,many many thanks👍🙏🙏..

  • @Solo6R
    @Solo6R5 жыл бұрын

    Appreciate the awesome series so far. I still reference your videos when I'm not 100% sure why something works. Anyways. REQUEST: Could you do a video on std::string_view vs. std::string, and when to prefer to use one or the other?

  • @redwing8725
    @redwing87253 жыл бұрын

    Thanks a lot, your videos are always the easiest to understand :)

  • @kgothatsontsane3119
    @kgothatsontsane31193 жыл бұрын

    Thank you. You're a legend!

  • @buddhasarchive8385
    @buddhasarchive83853 жыл бұрын

    thanks. great video as always

  • @Miketar2424
    @Miketar24246 жыл бұрын

    An important point that I realized looking at my casted variable types, the variables do not actually change to the casted types, only the data is changed. So the variable doubleVar = 5.5, will send 5 when casted as an int, but it still remains a double.

  • @syntaxed2
    @syntaxed26 жыл бұрын

    Any chance you can go more indepth with c++? E.g Software patterns, observer/subscriber/design/factory etc, how to structure/organise code, superclasses or not, how to achieve loose coupling etc. I feel all of this basic stuff has been done, its all over youtube, the horse is not beaten...its a wet pulp at this point :D Just a hint for future content!

  • @groberti

    @groberti

    5 жыл бұрын

    I don't think that those topics are C++ specific. It would be nice to have a new Cherno series dedicated to that but those topics would not fit into this C++ course imho

  • @calmsh0t

    @calmsh0t

    5 жыл бұрын

    He is right, it is C++ specific since many design patterns cannot be applied directly to c++ since they heavily use concepts introduced in higher level languages

  • @zvxcvxcz

    @zvxcvxcz

    4 жыл бұрын

    Those aren't things you would usually ask a game programmer. Games are not like many other large projects in this respect, often due to performance targets. Many of these patterns are really geared towards what I will call corporate code... where the assumption is that everyone else using your code is a moron that will ignore comments and abuse absolutely anything that can be abused and in the worst ways possible. Not to say that games don't have any overarching structure, they do. How do I put this though, it's not that they don't have design patterns, but they have different design patterns and they aren't patterns that most proponents of design patterns would approve of. Cherno's videos are good and necessary. Tales of the horse's demise are greatly exaggerated. He's pretty much the only person talking about these things on KZread that can actually convey them to an audience. He's the only one doing C++ videos that makes me feel like I'm back in my university courses listening to my prof rather than to some moron that either doesn't themselves know what they're talking about or with such poor communication skills that the only people that know what they're talking about are people that already knew the subject matter. Go watch some C++ con vids, none of them seem to be able to define lvalues and rvalues in a way that anyone that didn't already know them can understand. Watch Cherno a few minutes and it makes perfect sense.

  • @gayusschwulius8490
    @gayusschwulius84904 жыл бұрын

    It's amazing. I have been using C++ for half a decade and written quite a few rather complex programs, yet there are still features I didn't know, lol.

  • @ahmedbugti3152

    @ahmedbugti3152

    4 жыл бұрын

    What makes you use C++ so long?

  • @gayusschwulius8490

    @gayusschwulius8490

    4 жыл бұрын

    @@ahmedbugti3152 It's just the language I'm most comfortable with. It's also very powerful, versatile and (next to C) de facto industry standard in many areas of software design.

  • @parabalani
    @parabalani3 жыл бұрын

    I can't believe how accessibly you explained this

  • @Medak1337
    @Medak13376 жыл бұрын

    you make cool videos, keep it up

  • @jaywalkingly
    @jaywalkingly4 жыл бұрын

    thank you for this video

  • @abhisheksa6635
    @abhisheksa66359 ай бұрын

    Thanks

  • @funera3385
    @funera33854 жыл бұрын

    thank you alot you helped me alot

  • @joseponce6250
    @joseponce62502 жыл бұрын

    thanks

  • @gabrielbraz9669
    @gabrielbraz9669 Жыл бұрын

    A example of why would you need to cast something. { int sum = 27; int num = 5; double average_1 = sum / num; // average_1 = 5 double average_2 = (double) sum / num; // average_2 = 5.4 } Basically, because sum and num are both integers, the c++ will use the integer version of the division operator, and the result will be truncated into an int, before being assigned to the double variable. And in the second case, because of the type casting into a double, the double version of the division is used and the result is expected.

  • @_juanzu_
    @_juanzu_4 жыл бұрын

    Thanks ♥️

  • @MrHelio97
    @MrHelio974 жыл бұрын

    Although I'm making some effort to learn C++ style casts, I also prefer C-Style casts. The only thing that C++ style casts ( a part from dynamic_cast) have useful is improving code readability, but I see them somewhat confusing. Working with C-Style cast is far easier.

  • @yashratnani9877
    @yashratnani98773 жыл бұрын

    thank you

  • @erikeviston
    @erikeviston4 жыл бұрын

    Any updates on the dynamic casting video? Really interested in this as well as further information on RTTI and reflection in C++. Not something that is clearly and concisely explained online! Thank you for all your helpful videos.

  • @redcrafterlppa303
    @redcrafterlppa303 Жыл бұрын

    Implicit casts with data loss is one of the greatest sins of c/c++

  • @stewartzayat7526
    @stewartzayat75266 жыл бұрын

    Could you make a video about memory allocators, like memory arenas?

  • @pablo17349
    @pablo173492 жыл бұрын

    Hi Cherno! I am currently studing at 42 school, and your videos are so helpfull. So you know!

  • @shavais33
    @shavais333 жыл бұрын

    I feel like someone could learn C++ just as well from this video series as they would from a university computer science class. Just as well, if not better. The value here is just too high to consume in good conscience without proffering some level of support. I think I sense a Patreon subscription in my future.

  • @shavais33

    @shavais33

    2 жыл бұрын

    @Over Yonder I'm sorry to hear that your university experience was so terrible. At the time when I attended the university I went to, their computer science and computer engineering undergraduate programs were incredibly intensive.

  • @shavais33

    @shavais33

    2 жыл бұрын

    Oh I think you over state the case against going to university a bit. I can appreciate the sentiment, and you might be right when it comes to learning some particular programming language or something, but the engineering pro school I went through took me through big thick advanced textbooks on math, physics, chemistry, things like quantum mechanics and semiconductor physics. Power dynamics, signals and systems, properties of materials.. Things like calculus based discrete math that describe systems for proving (or disproving) the correctness of algorithms.. Electronics and micro electronics.. I built and programmed embedded systems in machine language, assembler, and then C.. advanced concepts in computer architecture.. I designed and simulated the operation of a microprocessor and used equipment whose output could be put into other equipment that would actually manufacture it.. It took me through the advanced details of operating system internals.. All kinds of things. Way too much to even list. I started with 1,000 peers and graduated with 100. Literally 90% washed out! I am probably upwards of the 96th percentile in terms of intelligence, and I found the program to be very challenging. I would never have learned all that stuff on my own, and I don't think I've really found on-line resources that nearly match all that. I still have a small book shelf full of the those big thick advanced textbooks. To me, the online materials I've come across seem more geared toward people with much closer to average intelligence than that of the audience targeted by my university textbooks. Not that you necessarily need all that stuff just to be a programmer, but. I would say that it doesn't hurt. My perception is that the vast majority of programmers I come across who don't have the kind of education background I have don't really think on same the level that I do. Even the ones who I would guess are actually a little smarter than I am. But again, all that said, I do think when it comes to learning about some particular programming language, you might be right that some online resources, like this one, rival or even do better than 1st or 2nd year university courses.

  • @darthnegativehunter8659
    @darthnegativehunter86594 жыл бұрын

    8:20 , no actually your explanation was perfect and very understandable. thank you

  • @ikefir
    @ikefir5 жыл бұрын

    Hi! Though I’m kinda late to the party, let me ask - what is your opinion on “warning: use of old-style cast”? And thanks for the content. Keep it coming!

  • @SankoshSaha_01
    @SankoshSaha_013 жыл бұрын

    any game engine with C++ is gonna give hell with this casting

  • @tlhomotsemoteme2423
    @tlhomotsemoteme24235 жыл бұрын

    You are the best!

  • @leonardomarinovic3492
    @leonardomarinovic34926 жыл бұрын

    So many oportunities to fuck up.

  • @NeoKailthas
    @NeoKailthas3 жыл бұрын

    If I type very strongly, does that make me a good cpp dev?

  • @cmdlp4178
    @cmdlp41786 жыл бұрын

    What about std::any_cast :D. (It is not an operator, just a function to cast a std::any in the new standard-library features.)

  • @krisitak
    @krisitak5 жыл бұрын

    Hello Yan. Can you do a video about CMake, makefiles and their alternatives in Visual studio.

  • @vivekshivhare8820
    @vivekshivhare8820 Жыл бұрын

    Can you make a series on design patterns?

  • @RWM_
    @RWM_3 жыл бұрын

    static_cast - compiler time conversion check dynamic_cast - runtime conversion check

  • @BinGanzLieb

    @BinGanzLieb

    Жыл бұрын

    for dynamic, you need RTTI

  • @mrboyban
    @mrboyban3 жыл бұрын

    Cherno you're a trouble mate.! Very a few people can type on a suit, good stuff! thanks

  • @kamran_aghlami
    @kamran_aghlami6 жыл бұрын

    ahhh nice one! I was hoping to see another OpenGL video though. ;) keep them coming!

  • @pooria_garrett3020

    @pooria_garrett3020

    6 жыл бұрын

    Hey man are you in Cherno discord server? come join us.

  • @kamran_aghlami

    @kamran_aghlami

    6 жыл бұрын

    Pooria GH I just created my acc on discord, aaaand seems like i’ve been missing this one. 👌

  • @kurt7020
    @kurt7020 Жыл бұрын

    "The compiler has looked at that and been like - that's never gonna work." - Sounds like most of my code. XD

  • @tianhepeng9162
    @tianhepeng91625 жыл бұрын

    Where is the in-depth dynamic_cast video? I find information from cppreference is so hard to understand. Hope the dynamic_cast video would come ~

  • @mattiamarchese6316
    @mattiamarchese6316 Жыл бұрын

    At 3:56 you can see Visual Studio transforming that 5.3 in 5.29999999999999

  • @Lightn0x
    @Lightn0x2 жыл бұрын

    1:05 implicit conversion can have data loss though, can't it? For instance, implicit conversion from double to int truncates to nearest int.

  • @dominikvereno8404
    @dominikvereno84045 жыл бұрын

    Would be awesome if you could make a video about regular expressions!

  • @darklord3227
    @darklord32275 жыл бұрын

    I have been programming in c++ professionally for a long time. Yet I still enjoy your videos! I mainly watch them for features that I don't normally use. I was wondering if you could create an episode on crash debugging. Thanks!

  • @ultimatesoup
    @ultimatesoup8 ай бұрын

    Just a note, but you should prefer ' ' over endl. Endl also performs a flush which makes it orders of magnitude slower. Another small correction, c style casts cannot perform dynamic cast behavior. It can do all the other types though. You should never const cast. Some people use it to add const to variables but a better way is to just use std::as_const

  • @SkSafowan
    @SkSafowan2 жыл бұрын

    please make another video about how to understand this video !!!

  • @AntiWanted
    @AntiWanted3 жыл бұрын

    Nice

  • @ChillerDragon
    @ChillerDragon6 жыл бұрын

    What shortcuts do you use to code that fast? It looks like your using vim instead of visual studio hehe. Would be nice to see a video about that.

  • @peterarbeitsloser7819

    @peterarbeitsloser7819

    3 жыл бұрын

    Just use vim

  • @sumitparwal4086
    @sumitparwal40863 жыл бұрын

    can you explain about inheritance in nested class as in can the classes inherited by enclosed class will also be inherited by nested class if not how can we include them

  • @astaghfirullahalzimastaghf3648
    @astaghfirullahalzimastaghf36483 жыл бұрын

    Man I need your help, I want to cast an int variable of an array into string or bool or maybe a constant number. i.e int *arrayPointer=new int[ 5 ]; Then i want to just represent the *arrayPointer in smaller byte size, Because later I would like to check whether the user input insert the correct number in the correct order. This can be used to create a new programming language! Thanks

  • @TheKimpula
    @TheKimpula2 ай бұрын

    I learned everything about casting from this video except why we need casting and what does it do. Like what is a static_cast?

  • @jannesopanen8032
    @jannesopanen80323 жыл бұрын

    Hey do you use laptop's internal mic or do you have external one ?

  • @sirfalcon1
    @sirfalcon15 жыл бұрын

    Do you have a video on Try Catch error handling?

  • @joesmackdown
    @joesmackdown6 жыл бұрын

    Const cast removes const from memory, this only works with pointers: const int* constValue = new int(5); int* nc = const_cast(constValue); *nc = 7; cout

  • @poganka45
    @poganka456 жыл бұрын

    you're the modern day superhero!

  • @catomajorcensor
    @catomajorcensor3 жыл бұрын

    C++ is not strongly typed, it is very much weakly typed("if (3)"), but it is statically typed.

  • @haxterhuz8346
    @haxterhuz83466 жыл бұрын

    Hey Cherno can you do a series on making an interpreter or compiler for a toy language?

  • @obinator9065
    @obinator90656 жыл бұрын

    Can you do a video on iterators?

  • @dockstaal7110
    @dockstaal71106 жыл бұрын

    lol I was just learning about this for my exams and now you upload a video about it.

  • @Katniss218
    @Katniss2184 жыл бұрын

    6:45 How is searching for "(int)" not practical?

  • @SatyajitSatoDas

    @SatyajitSatoDas

    4 жыл бұрын

    Because you will have to search for all datatypes like that? In case of C++ style cast you will just need to search for 4 types at max.

  • @bloodwolf8307
    @bloodwolf83074 жыл бұрын

    cool

  • @slayer5171
    @slayer51716 жыл бұрын

    Hello, would you make a video about exception and exception handling?

  • @yayaskurt
    @yayaskurt6 жыл бұрын

    Hey, would you make a video explaining object slicing?

  • @TheCherno

    @TheCherno

    6 жыл бұрын

    Yes! Good idea

  • @peterarbeitsloser7819

    @peterarbeitsloser7819

    3 жыл бұрын

    What is that?

  • @exodus8814
    @exodus88146 жыл бұрын

    Hello all. I'm having a hard time understanding pointers, I'm okay with everything else in C++, like classes, structs, templates, polymorphism etc.. It's just pointers that i don't really understand. For example, why do we use const char* message;? Why does it have to be const? Even without const we still cannot change the contents in message. Furthermore, why do we have const char* message and char* const message? How can a pointer be constant? Add to that, what is char** argv or argv[]? Malloc, calloc, realloc, free?? Why should I create a variable on the heap? When? Why? What does it give? Why should I free/delete the variables created on the heap? I have soo much in mind, if anyone could help, I appreciate it a lot. Thanks

  • 6 жыл бұрын

    I think Cherno made a really good video explaining pointers

  • @anandkrishna590

    @anandkrishna590

    6 жыл бұрын

    The thing you forgot is this is CPP. Ok i will agree that's cringy. For tips I'm a newbie so I'll just recommend you watch all his vids on cpp and others too. Dont take my word for it though.

  • @exodus8814

    @exodus8814

    6 жыл бұрын

    Nikola Kostić Thank you very very much for that detailed answer! I appreciate it, sorry if this was too much, I come from high level languages so the concept of pointers and low level stuff is pretty confusing, I tried googling questions and I actually found answers, but still the concept was pretty hard to grasp. Thanks a lot for your time :)

  • @haxterhuz8346

    @haxterhuz8346

    6 жыл бұрын

    I would suggest a book called Effective C++. Its really good

  • @owiley2002

    @owiley2002

    6 жыл бұрын

    The idea behind pointers isn't really a new concept. Think about everyday interactions. Let say that your love one like a grandma wants to give you a present. One way is to visit you directly and give you the present. This is sending you a value directly. But what if I she cannot directly visit you? The next way is sending it via mail or by some address. This is exactly what pointer does. A pointer is a variable which holds data that is the address of something. Your grandma probably has and address book that holds this information and other things like maybe a birthday tracker or planner. The idea is to be able to store a reference to some location becomes key in computing. Some things can not be loaded all at once on a computer, so knowing where it is located becomes very important. The heap vs stack is away to address this problem by having some promises that at least this much information can be seen at once. Later on you will come to see that certain things do not physically exist as limitation but are abstracted ideas that are imposed on the system of computing.

  • @samkenneth6251
    @samkenneth62516 жыл бұрын

    Are you going to do more Sparky episodes??

  • @Spiderexe
    @Spiderexe5 жыл бұрын

    the reinterpret_cast at 7:50 doesn't work for me. other than that, great video :D

  • @GenjaOrigins
    @GenjaOrigins2 жыл бұрын

    Videos of HashMap HashSet etc please

  • @pepesilvia3776
    @pepesilvia3776 Жыл бұрын

    bruh, that decor is nasty af.

  • @andrez383
    @andrez383 Жыл бұрын

    Cherno, you should have used a black couch for this episode :)

  • @garageman2236
    @garageman22363 жыл бұрын

    Syntax sugar!

  • @michael541
    @michael541 Жыл бұрын

    Do you know what native advertising is?))

  • @pnuema1.618
    @pnuema1.618 Жыл бұрын

    The word "static" always refers to "compile time"

  • @cavidanbagiri1884
    @cavidanbagiri18845 жыл бұрын

    hi Cherno. why dont you create c++coursein udemy. please create course and speak about c++ and mysql connection and some function. Thank you very much

  • @osere6432
    @osere64325 жыл бұрын

    Bit fields please?

  • @dms2472
    @dms24726 жыл бұрын

    Next , videos about shortcat typing for more productive coding pliss

  • @kamendolievaleksandar233
    @kamendolievaleksandar2336 жыл бұрын

    Make video about dynamic cast asap!

  • @snookiewozo
    @snookiewozo3 жыл бұрын

    A very chaotic video.

  • @christomaliyekkal8381
    @christomaliyekkal83816 жыл бұрын

    Could you please add tutorials on websocket? Create websocket services using C++, Websocket client, etc.

  • @Xgamesvidoes
    @Xgamesvidoes4 жыл бұрын

    Thanks! :D

  • @gabrielbarrantes6946
    @gabrielbarrantes69467 ай бұрын

    Is casting a good practice? I feel is so dirty that should only be done if you are looking to implement something not readable but quite efficient like que quake algorithm lol

  • @valizeth4073
    @valizeth40736 жыл бұрын

    Could you answer why you need to typecast the C function malloc? like char* ptr; ptr = (char*)malloc(size * sizeof(char)); ??

  • @TheSiddh123

    @TheSiddh123

    6 жыл бұрын

    I guess because malloc returns a (void *) , also malloc does not know for which type we are allocating memory for so we have to cast it back ( size is provided using sizeof(type) , in your case its sizeof(char))

  • @valizeth4073

    @valizeth4073

    6 жыл бұрын

    I know how you use malloc to allocate sizes and so on, just didn't get the casting.

  • @joshstephenson2475

    @joshstephenson2475

    6 жыл бұрын

    +Vali Zeth - C++ has more type safety than "C". "C" doesn't care what type you assign a void pointer (void*) to, so you could assign a void pointer to anything without it caring, but C++'s extra type safety needs you to explicitly tell the compiler what type you want the void pointer casted to, because a void pointer is a pointer to anything (unknown type)...

  • @valizeth4073

    @valizeth4073

    6 жыл бұрын

    One thing I still haven't gotten though is why pointers are of type void. A pointer returns a memory address of an object / variable. The address is still a value though, void = emptiness. So how can it return an adress and yet nothing at the same time?

  • @joshstephenson2475

    @joshstephenson2475

    6 жыл бұрын

    +Vali Zeth - A void pointer is just a RAW Address. It is basically like saying, that whatever receives this pointer can treat the memory space at that address as any type it would like. So if I cast a void* to a char* ("char* ptr = (char*)malloc(10)"), I'm just telling the compiler that i want to either read or write to this address as the value type of "char" (1 byte data type). I could also say I can cast the void* to a int* ("int* ptr = (int*)malloc(10)"), I'm telling the compiler that I want to either read or write to this address as a value type "int" ( 4 byte data type) So as you can see, i can treat a void* as anything I want due to the fact that the compiler doesn't actually know what is at that address because it is a pointer to an "Unknown data type" (void*)...

  • @Beatsbasteln
    @Beatsbasteln4 жыл бұрын

    did anyone notice that he is at different places in almost every video? how does he even do that?

  • @zanityplays
    @zanityplays6 жыл бұрын

    yeet

  • @erwinschrodinger2320
    @erwinschrodinger23203 жыл бұрын

    Amazin.

  • @bextract0
    @bextract06 жыл бұрын

    yeeeeeeeeeeeeeeeeeeeeeeeeeet

  • @neeraj33negi

    @neeraj33negi

    6 жыл бұрын

    Bextract YOTE 🤔😥😥

  • @yee3135

    @yee3135

    6 жыл бұрын

    yee

  • @connorhorman
    @connorhorman6 жыл бұрын

    I think that not everything can be done with a c-style cast. If x is an int or an int&, I can static_cast it to int&&, but do (int&&)x. (can't convert an lvalue expression to an xvalue, but static_cast can transform types from an lvalue to an xvalue. (Though not directly to a prvalue.)

  • @crait
    @crait Жыл бұрын

    Yeah, you can search for casting without static_cast if you use the constructor-style casting.

  • @fidanrli7456
    @fidanrli74566 жыл бұрын

    Hi could you explain inline function ? and storage class? These are my exam questions .

  • @vertigo6982
    @vertigo69825 жыл бұрын

    06:42 Nobody: Vim users: "Hold my beer" see that.. 2 memes in 1.

  • @GohersWay
    @GohersWay3 жыл бұрын

    7:47

  • @michaltch9246
    @michaltch92466 жыл бұрын

    Can u please make video about filling code with module tests? Using boost c++ libraries.

  • @zikdoz
    @zikdoz6 жыл бұрын

    Isn't it better to check for nullptr instead of regular 0 (or NULL macro) with dynamic casts?

  • @jamesmnguyen

    @jamesmnguyen

    6 жыл бұрын

    zikdoz Quick answer: no Long answer: Nullptr means, just that, a null pointer. So checking a pointer with nullptr makes sense. Technical answer: it doesn't matter, but you'll lose friends.

  • @jamesmnguyen

    @jamesmnguyen

    6 жыл бұрын

    itsArtem The first example shows what's going on in memory, the second shows what you're trying to do.

  • @sushant_
    @sushant_6 жыл бұрын

    Which softeware are you using for this programming?

  • @spiderman8883

    @spiderman8883

    4 жыл бұрын

    Visual Studio

  • @sabanburaknazlm1381
    @sabanburaknazlm13816 жыл бұрын

    Hi guys! I have trouble with glsl shading language. I use #version 120 because of my hardware. I've tried inverse function for lighting but i can't use it. It needs minimum #version 150. Is there other option than using inverse function?

  • @Alonedream15
    @Alonedream156 жыл бұрын

    We want video about cmake & llvm plese . What are thay?