C++ Programming Tutorial 68 - Swap Function with Pass by Reference

Поделиться
HTML-код
  • Опубликовано: 2 дек 2024

Комментарии • 20

  • @MorbidPasta
    @MorbidPasta 2 года назад +8

    The way that I swap ints without using a temp if anyone is interested:
    void swap(int &a, int &b){
    a = a + b;
    b = a - b;
    a = a - b;
    std::cout

  • @guitarhax7412
    @guitarhax7412 5 лет назад +10

    Okay, this one really tied in in better. You almost lost me last video. This was a good enforcer.

    • @Charles.Wright
      @Charles.Wright 3 года назад +1

      For a different perspective, I already "knew" much of the content of this video, specifically how things behaved. But I didn't understand that data is COPIED, which he mentioned early in the previous video.

    • @liampapavasiliou9658
      @liampapavasiliou9658 3 года назад +2

      WHYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY EVERY SINGLE VIDEO

    • @PunmasterSTP
      @PunmasterSTP 3 года назад

      @@liampapavasiliou9658 Why not, Liam? Why not?

  • @spinity8468
    @spinity8468 3 года назад +3

    This code is really good Caleb! :D Thanks!

  • @kern68
    @kern68 3 года назад +1

    After watching episode 66-68 I extrapulated that const should be used only when passing arrays to functions. Since all other types are passed by value unless you want the function to have the ability to change the value. Am I understanding this correctly?

  • @DieGedankenSindFrei0
    @DieGedankenSindFrei0 2 года назад

    What about swapping back to the original numbers? I want to swap to use for calculation purposes, but then use the original numbers for printing purposes. New to C++. TIA!

  • @rdawo6408
    @rdawo6408 4 года назад +3

    can we use it for strings?

  • @72Yusif
    @72Yusif 7 месяцев назад

    Please tell me how i can do it without any integer on my code. I want to just type two numbers on terminal then i want to got output . For example
    Terminal:
    10 5
    5 10.
    . I want to do exactly like that. And i want to left 1 space beatwen integers on terminal also. Beside i want to write just function on my code to implement this output on my terminal.

  • @aaronzewdu
    @aaronzewdu 2 года назад

    Fantastic example

  • @bennythinker4659
    @bennythinker4659 5 лет назад +2

    awesome video

  • @PunmasterSTP
    @PunmasterSTP 3 года назад

    Hey, did you hear about this IDE that dogs can use to code? ...Sorry, I forgot the punchline. Maybe it was related to a sponsor or something?

  • @kabarii
    @kabarii 2 года назад

    THANK GOD bro i was going insane wondering why the numbers weren't swapping, its cause i forgot the &

  • @advaithrvasistha44
    @advaithrvasistha44 8 месяцев назад

    tnks

  • @jonverperfecto3330
    @jonverperfecto3330 2 года назад

    Thanks

  • @liatris69
    @liatris69 3 года назад

    0:55