C++ Programming Tutorial 94 - Overloading Insertion and Extraction Operators

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ก.พ. 2025

ความคิดเห็น • 31

  • @thatskap
    @thatskap 3 ปีที่แล้ว +6

    first vid that actually explains each of the keywords and symbols for the operator overload instead of just writing the overload with no further elaboration.

  • @nguyentrongphuc821
    @nguyentrongphuc821 4 ปีที่แล้ว +20

    thank your for this, I didn't really know what my teacher was teaching until this

  • @aungshanhtay357
    @aungshanhtay357 3 ปีที่แล้ว +2

    Dear bro, I just did it the get line overload and it works. Thank you bro. I just started learning C++ by watching your tutorials. Yeahhhhh
    istream& getline (istream &input,User &user) //extration operator syntax getline(note: reference at object)
    {
    getline(input,user.first_name);
    getline(input,user.last_name);
    return input;
    }

  • @omrozh
    @omrozh 4 ปีที่แล้ว +7

    This tutorial series is great I have been following along since the first tutorial and I learned a lot.

  • @northtrade6814
    @northtrade6814 3 ปีที่แล้ว

    I had to go over this a couple times, which was well worth it, as I walked away with an understanding of operator overloading, rather than to put it off until later. Yet another tool in the arsenal in the C++ language thanks to Caleb Curry's tutorial. Thank you, sir.

  • @sajjadjafari2612
    @sajjadjafari2612 3 ปีที่แล้ว +1

    You made it as easy as a piece of cake for me as a beginner.
    liked and subscribed.

  • @tanzengyang3760
    @tanzengyang3760 4 ปีที่แล้ว +1

    Actually you can use previous example:
    Position y;
    y.y = 5;
    cout

  • @pierfrancescopeperoni
    @pierfrancescopeperoni 3 ปีที่แล้ว +2

    This is gold.

  • @PunmasterSTP
    @PunmasterSTP 3 ปีที่แล้ว +1

    Extraction? More like extraction of ignorance, and replacement with knowledge! Thanks again so much for this wonderful tutorial series.

  • @typical_yt8525
    @typical_yt8525 3 ปีที่แล้ว +2

    For people who got the error "Too many parameters for this operator function"
    Declare the function in the class as a friend, and then define the function outside of the class. Example:
    class Position
    {
    public:
    int x = 10;
    int y = 20;
    friend std::ostream& operator

    • @justinmyowin8639
      @justinmyowin8639 2 ปีที่แล้ว

      Thanks a ton

    • @scullyy
      @scullyy ปีที่แล้ว

      Ok, but why does that work?

  • @liza-mariwright9697
    @liza-mariwright9697 ปีที่แล้ว +1

    How do we overload insertion and extraction operators as a member function inside a class? This explanation works wonderful, but when I try to put it as member function in a class, it says that there is no match for the operator

  • @armandduval4893
    @armandduval4893 2 ปีที่แล้ว

    Great video! Thanks a lot!

  • @brocklesnarufcchamp1
    @brocklesnarufcchamp1 3 ปีที่แล้ว +1

    This was actually less confusing than the previous video.

  • @cafelashowerezweb
    @cafelashowerezweb 5 ปีที่แล้ว +1

    The second parameter of extraction overloading function is passed by reference.
    Does this mean that the reference allows us to change an user object to another?

  • @idontknow472
    @idontknow472 3 ปีที่แล้ว

    Great stuff

  • @maxim25o2
    @maxim25o2 3 ปีที่แล้ว

    I see another example in my school,
    as public member of class _____ void operator

  • @eien7228
    @eien7228 3 ปีที่แล้ว +1

    i have a question, is there any way to return ostream without returning reference, i kno this is useless but i just wanna kno

  • @varunpoondi2772
    @varunpoondi2772 4 ปีที่แล้ว +3

    When I add in User into the operator overloading function parameter, I get the error "too many parameters for this operator function", but when I add it in a friend, this error goes away. Can someone explain why this is happening?
    ostream& operator

    • @yumengliu8347
      @yumengliu8347 3 ปีที่แล้ว

      @@brandonmeeker6377 Thanks

  • @bikramkeshariswain7980
    @bikramkeshariswain7980 ปีที่แล้ว

    please explain layman term in insertion and extraction overloading , kindly i can't understand .please listen my voice.

  • @KzrLancelot
    @KzrLancelot ปีที่แล้ว

    Have a question : why would i use this instead of adding a method to print out each object?

    • @Byynx
      @Byynx ปีที่แล้ว

      One of the reasons is a cleaner code.

  • @jpviscaino
    @jpviscaino 3 ปีที่แล้ว

    Why can't we do copies of the ostream? I know it's bad practice but would it even be possible?

  • @GOODBOY-vt1cf
    @GOODBOY-vt1cf 2 ปีที่แล้ว

    2:44

  • @rasum186
    @rasum186 4 ปีที่แล้ว

    I tried the input without returning anything (with a void type) and it worked. Is it supposed to be done like I did?

    • @jpviscaino
      @jpviscaino 3 ปีที่แล้ว

      @@brandonmeeker6377 best answer to that specific question I've seen.