How are strings printed without calling an operator function?

I'm wondering how a string variable "x" can be printed out by just typing "x", without any parentheses in the end. I understand that int and char etc. can be printed out that way, but string is a class type containing an array of chars, and is thus not a fundamental data type in C++.
I assume you're taking about using the << operator to output to a stream, yes?

It's possible, because you can overload the << operator for any type. The standard library includes such an overloaded operator for the std::string class, but you can write one for any class.
You're right. The << operator function calls a function to print the string, and this function can do whatever it wants to accomplish this task.
Topic archived. No new replies allowed.