Originally Posted by
Niccolo
@rm82co
The constructor is a function "called automatically" in the sense that it is part of construction. Study on the subject of constructors and destructors.
The destructor is a function "called automatically" when the string falls from scope (is otherwise deleted as the member of another class/struct).
When using operators like << or + or +=, these are actually ways of calling functions, in this case operator functions. I wouldn't say this is "automatic", but it might fit what you're thinking. They are not really "automatic" because these operators are functions in classes like string, but you might be thinking of them as automatic merely because the syntax is not that of a member function call like s.c_str(); It would be an error, really, to think they are automatic. This is also true of the assignment operator "=".