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

preview_player
Показать описание


~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

🅑 Bitcoin - 3HnF1SWTzo1dCU7RwFLhgk7SYiVfV37Pbq
🅔 Eth - 0x350139af84b60d075a3a0379716040b63f6D3853
Рекомендации по теме
Комментарии
Автор

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

nguyentrongphuc
Автор

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. <3

thatskap
Автор

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.

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;
}

aungshanhtay
Автор

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

omrozh
Автор

Actually you can use previous example:

Position y;
y.y = 5;
cout << "What the new value of Y"<<endl;
//Compiler know how to insert y value to y
cin >> y;
//y is updated to user input value
cout << y << endl;
really like your explanation

tanzengyang
Автор

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 << (ostream& output, User user){
return output;
}

This is not compiling

varunpoondi
Автор

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

PunmasterSTP
Автор

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

sajjadjafari
Автор

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.

northtrade
Автор

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 << (std::ostream& output, Position user);

private:

};

std::ostream& operator << (std::ostream& output, Position user)
{
output << "x" << user.x << "y" << user.y;
return output;
}

int main()
{

}

typical_yt
Автор

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?

cafelashowerezweb
Автор

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 <<

liza-mariwright
Автор

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

eien
Автор

This was actually less confusing than the previous video.

brocklesnarufcchamp
Автор

I see another example in my school,
as public member of class void operator << ( ostream &);
and later in main program call just that obiect cout << kogel ;
function class ____ void kogel::operator << ( ostream &OS ){ OS << " example " << diameter ;}
Is not easier to just create instance in side of class?? Why everybody are creating overloaded ostream outside of class??
What is difference between your example and creating overloaded operator in side in class?

maximo
Автор

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

KzrLancelot
Автор

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

lordnoiado
Автор

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

bikramkeshariswain
Автор

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

rasum