1. Why do I have to reference the object output and the return ostream object ?
You don't want to copy the stream object so you have to pass/return it by reference.
2. Why have to use two parameters ,since there is already a return ostream object ?
The << operator takes two arguments. The first argument is the stream object and the second argument is the object that you want to output.
cout << z; is the same as calling operator<<(cout, z); If you write it like this it will compile and do exactly the same.
The return value allows you to chain more calls to << right after.
cout << z << x; is the same as operator<<(operator<<(cout, z), x); It simply passes the return value of the first << as the first arguments to the next <<.
3.What if the return type can be void ? return nothing, since I just need it print something .
If the return type is void you can't chain any more << after it. You would have to split the printing over multiple statements.
1 2 3 4 5 6
// This would not work if << had return type void.
cout << z << x; // error!
// Instead you would have to write it like this.
cout << z;
cout << x;