This might be a beginner question and understanding how cout works is probably key here. If somebody could link to a good explanation, it would be great.
cout<<cout and cout<<&cout print hex values separated by 4 on a linux x86 machine.
This might be a beginner question and understanding how cout works is probably key
Share
cout << coutis equivalent tocout << cout.operator void *(). This is the idiom used before C++11 to determine if an iostream is in a failure state, and is implemented instd::ios_base; it usually returns the address ofstatic_cast<std::ios_base *>(&cout).cout << &coutprints out the address ofcout.Since
std::ios_baseis a virtual base class ofcout, it may not necessarily be contiguous withcout. That is why it prints a different address.