B
block111
Hello,
code like this:
int f1(int x){
int f2(int y){
return y*y;
}
if(x > 0)
return f2(x);
else
return -1;
}
is invalid. functions cannot have nested functions in c++. I read
comparison d vs other programming languages
http://www.digitalmars.com/d/comparison.html
it says that d has nested functions and other s don't. But I always
used a construct that gives effect of nested function, and I'd like to
ask if such code is valid according to the standard.
int f1(int x){
struct {
int operator()(int y){ return y*y; }
} f2;
if(x > 0)
return f2(x);
else
return -1;
}
Thanks
code like this:
int f1(int x){
int f2(int y){
return y*y;
}
if(x > 0)
return f2(x);
else
return -1;
}
is invalid. functions cannot have nested functions in c++. I read
comparison d vs other programming languages
http://www.digitalmars.com/d/comparison.html
it says that d has nested functions and other s don't. But I always
used a construct that gives effect of nested function, and I'd like to
ask if such code is valid according to the standard.
int f1(int x){
struct {
int operator()(int y){ return y*y; }
} f2;
if(x > 0)
return f2(x);
else
return -1;
}
Thanks