Answer the question
In order to leave comments, you need to log in
Are there ready-made solutions in C++ for implementing the toString method?
Actually, the whole question is in the title: is there a tool in C ++ that allows you to perform something similar to toString on class objects?
Answer the question
In order to leave comments, you need to log in
What you call toString is, in C++ terminology , a type conversion operator to a string representation.
For your class X, you describe:
or (with certain difficulties):
And then in the code you use:cout << X;
#include <string>
....
to_string(); есть уже с с++11.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question