Reference Variables | C++ Tutorial

Поділитися
Вставка
  • Опубліковано 15 гру 2024

КОМЕНТАРІ • 9

  • @yt-1161
    @yt-1161 9 місяців тому

    11:15 what if the function accepts many arguments of different types ?

  • @germankoga8640
    @germankoga8640 Рік тому

    So, reference variables would still be memory adresses to the variable the've been set to point to, just in a safer way because it disallows certain behavior of pointers? and also they seem to get derreferenced automatically

    • @PortfolioCourses
      @PortfolioCourses  Рік тому +1

      Great question Brandon! :-) Technically a reference is an alias for another variable. So it's not really a pointer, so much as it is just another way of accessing another variable. Which is something we can do with pointers too, so yes as a practical matter it does feel like a 'safer' constant pointer with automatic dereferencing. But technically, within the C++ language, it's just another name and way to access another variable. We could say that a pointer points to another variable, but a reference *is* the variable.

    • @germankoga8640
      @germankoga8640 Рік тому

      @@PortfolioCourses Oh it's just that I got confused by the use of the & which in C was to reference a variable's memory adress, so I thought here it was more or less the same principle, and also I didn't see in first sight why would I want an alias variable, thank you for the fast answer, I'm introducing myself from C to C++ with this playlist, also I take the opportunity to suggest the video ideas of lambdas(interested in the functional programming features of cpp), smart pointers and RAII pattern, thanks again, I also used the C playlist to get deeper into that

    • @PortfolioCourses
      @PortfolioCourses  Рік тому +1

      Those are all great ideas and videos I want to make one day. :-) I'm glad you're enjoying the playlists!

  • @nurr_codee
    @nurr_codee 3 місяці тому

    Your are awesome.
    Thank You!

  • @rakshithabk1827
    @rakshithabk1827 2 роки тому

    Please make video for add line numbers to a file . The file name should be as command line arguments

    • @PortfolioCourses
      @PortfolioCourses  2 роки тому +1

      Thank you for the idea! I will add this to my list of video ideas. :-)

    • @PortfolioCourses
      @PortfolioCourses  2 роки тому +5

      I just published the video now: Add Line Numbers To A File | C Programming Example
      ua-cam.com/video/MbDwut1b1hE/v-deo.html. :-)