New course! Every coder should learn Generative AI!
Try a free lesson0
Can we make a return type of our own choice in c++
5 Answers
+ 3
what do you mean with return type? you can use any return type for a function, but then you also have to return it. Or do you mean making an own data type and using it as return type?
+ 3
how Travis already stated above you need to make a class or a struct, it can have instance variables, methods and so on, just look it up, after you've done that you can use the name of your class as data type
+ 2
Yes, you can. You'll have to define a struct or a class and that can be the return type.
class Foo {
// define class or struct
};
Foo someMethod () {
Foo foo;
//do something
return foo;
}
0
making own datatype
0
how to create datatype