+ 2
How to return an object from a function in c++?
2 Answers
+ 2
class cls {
public:
int a;
};
cls func() {
cls obj;
obj.a = 5;
return obj;
}
A class can be thought of as a new data type, so you can use them in the same ways as a data type. String in C++ is actually a class, too.
+ 2
Try operator overloading
https://code.sololearn.com/cx3kuuMj70tl/?ref=app