Darren New <dne### [at] san rr com> wrote:
> I find it mildly distracting that I can't do this:
> void xyz() { ... }
> void abc()
> {
> if (...)
> return xyz();
> else blah blah blah;
> }
I assumed this to be so in C++ without actually checking. However, now
that I checked it, it seems to work. For example:
//----------------------------------------
#include <iostream>
void bar() { std::cout << "bar()\n"; }
void foo(int i)
{
if(i < 0) return bar();
std::cout << "foo()\n";
}
int main()
{
foo(1);
foo(-1);
}
//----------------------------------------
compiles and runs just fine.
--
- Warp
Post a reply to this message
|