C++ overloaded functions explained 🍕

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

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

  • @BroCodez
    @BroCodez  2 года назад +12

    #include
    void bakePizza();
    void bakePizza(std::string topping1);
    void bakePizza(std::string topping1, std::string topping2);
    int main()
    {
    //bakePizza();
    //bakePizza("pepperoni");
    //bakePizza("pepperoni", "mushroom");
    return 0;
    }
    void bakePizza(){
    std::cout

  • @Hanyamanusiabiasa
    @Hanyamanusiabiasa 2 года назад +11

    This is a new concept as a python developer!

  • @criminalx7099
    @criminalx7099 2 года назад +1

    well explained bro

  • @ItzScale
    @ItzScale Год назад +1

    Can u pls explain to me why do we use void when we are accepting a string? Or am i stupid and it's not accepting, but returning?

    • @disabledfabrication
      @disabledfabrication Год назад +17

      the "void" keyword is a RETURN TYPE. In general, let's always assume that all methods have to return something, but in our case, we don't have to return anything, so we would put "void" instead of "int, boolean, double, etc..." Just assume that computer scientists who made this programming language decided to work on this way.
      To understand this, let's think of a real-life example.
      Imagine you have a friend's mom who loves to bake cookies.
      Usually, when your friend's mom bakes cookies, they give you some cookies to eat.
      But imagine one day your friend's mom tells you, "I'm going to bake some cookies, but I won't be giving you any."
      In this case, your friend's mom is not returning any cookies to you.
      In programming, it's similar. The "void" keyword is like your friend saying, "I'm not going to return anything." Instead of using specific types like numbers or true/false, we use "void" to show that the method doesn't need to give anything back.
      So, when you see "void" in a program, it means that the method doesn't have to return a value. This allows programmers to write methods that perform certain actions without worrying about producing a specific result.

    • @nguyenquochoa3117
      @nguyenquochoa3117 Год назад +1

      @@disabledfabrication this is a great explanation and good example, thank you i understand it

  • @NgJunLiang-s8u
    @NgJunLiang-s8u 10 месяцев назад

    Don't understand why previous function "Here is your pizza" will not cout ? is cover already so why delete it for waste space??

  • @FrederikWollert
    @FrederikWollert 9 месяцев назад

    I really like your C++ series. Keep it up. Please make more C++ Videos. So, let's defeat the RUclips algorithm.

  • @yamenzeadneh
    @yamenzeadneh 2 месяца назад

    thanks Bro you saved me at the night before my exam

  • @norscout3031
    @norscout3031 3 месяца назад

    Thank you!

  • @yellowhellow-wi9gi
    @yellowhellow-wi9gi 3 месяца назад

    thank you

  • @shanonhitler2229
    @shanonhitler2229 15 дней назад

    Truly a chad

  • @criminalx7099
    @criminalx7099 2 года назад +5

    well explained bro