+ 2

How to return an object from a function in c++?

4th Feb 2018, 8:10 PM
aravind
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.
4th Feb 2018, 8:49 PM
Jacob Pembleton
Jacob Pembleton - avatar
4th Feb 2018, 8:59 PM
Manual
Manual - avatar