POV-Ray : Newsgroups : povray.off-topic : Computer language quirks : Re: Computer language quirks Server Time
30 Jul 2024 02:17:46 EDT (-0400)
  Re: Computer language quirks  
From: Warp
Date: 11 May 2011 15:57:32
Message: <4dcaea2c@news.povray.org>
Darren New <dne### [at] sanrrcom> 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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.