Return x

Hello!
Please, can we sort what kinds of values we can get returned by return statement?

int
char
string
double
float
from an array w ecan get just pointer
etc

can someone contribute?
Many thanks!
There is no use in making a list like that, because you end up listing all the types in the world.
Can a function be returned by return statement?
Does someone know an easy example?
Rather than answering, lets ask: where/how would you use it?
@op: please expand because i dont quite understand what you are asking. also as to the third post, you kind of can. std::function is what you are looking for i believe.

@kes: or rather than bothering op with questions, we can answer them. why would we ask that? it could be just for learning purposes
enemy wrote:
Can a function be returned by return statement?
Does someone know an easy example?
http://ideone.com/CEl7ON
@Bobby: Bother? For learning purposes. Nothing forces you to think, if you just get an answer, but when you try to answer you should think and learn.

An no, a function may not return value that has a type of array or function.

http://publib.boulder.ibm.com/infocenter/comphelp/v7v91/topic/com.ibm.vacpp7a.doc/language/ref/clrc07fundec.htm#fundec
Last edited on
you actually are being forced to think, because you first have to think of the question... and there doesnt always have to be a problem or a reason to use it. for example i havent yet come across a reason to use #pragma anywhere in my code,but iwant to use it and cant think of a situation, but that doesnt mean there isnt. and even if i could think of one what would that achieve? it wouldnt advance my code. and actually you can return a type of array and/or function. you use std::function or std::array. do some research first.
I did. Blame the IBM.

std::function is a copyable object. It is not a function.
std::array is a copyable object. It is not an array.
What an object contains is secondary here.

Semantics, but compilers are rather pedantic about it.
of course std::function isnt a function. its a better version of c's function pointers. if you return it you are essentially returning a function. std::array is an array... i dont see where you got that from. its not the built in array but it is in fact an array
Topic archived. No new replies allowed.