how does cout << actually work?
问题 I was wondering how std::cout is able to use << as it does. My main puzzlement is with whether std::cout as an instance of something. Basically, how is << defined? If I do this for a custom class, I need an instance of some sort... I could see implementing it as kind of a hack with void pointers or something, but I'd like to see the actual way it's done. Does anyone here know? Thanks 回答1: std::cout is an instance of std::ostream . std::cout << "something" calls one of the operator<< overloads