🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: de.comp.lang.c++
3 messages
3 total messages Started by Joerg Bornemann Tue, 09 Apr 1996 11:06
Verschachtelte Funktionen
#2047
Author: Joerg Bornemann
Date: Tue, 09 Apr 1996 11:06
18 lines
603 bytes
Hallo...

Kann ich in C++ verschachtelte Funktionen basteln? Wenn ja, wie?

Folgendes funzt nicht:

void eins(int a);
{
	void zwei();
}

void zwei()
{
	a = 12;  //kein Zugriff auf a möglich :-(
}


cu Joerg <Joerg.Bornemann@rostock.netsurf.de>
Re: Verschachtelte Funktionen
#2050
Author: Dietmar Kuehl
Date: Tue, 09 Apr 1996 13:03
25 lines
1147 bytes
Hi,
Joerg Bornemann (Joerg.Bornemann@rostock.netsurf.de) wrote:
: Kann ich in C++ verschachtelte Funktionen basteln? Wenn ja, wie?

: void eins(int a);
                  ^
		  Das ist vermutlich aus Versehen da?
: {
: 	void zwei();
: }

: void zwei()
: {
: 	a = 12;  //kein Zugriff auf a möglich :-(
: }

Direkt und ohne Argument zu 'zwei()' geht das nicht. Mit einem Argument
fuer 'zwei()' kann man das allerdings einfach einrichten:

  void eins(int a)  { zwei(a); }
  void zwei(int &a) { a = 12; }
--
dietmar.kuehl@uni-konstanz.de
http://www.informatik.uni-konstanz.de/~kuehl/
I am a realistic optimist - that's why I appear to be slightly pessimistic
Re: Verschachtelte Funktionen
#2115
Author: Joerg Bornemann
Date: Sat, 13 Apr 1996 17:15
24 lines
947 bytes
kuehl@uzwil.informatik.uni-konstanz.de (Dietmar Kuehl) wrote:

>: void eins(int a);
>                  ^
>		  Das ist vermutlich aus Versehen da?

Oops...natürlich.

[...]

>: void zwei()
>: {
>: 	a = 12;  //kein Zugriff auf a möglich :-(
>: }

>Direkt und ohne Argument zu 'zwei()' geht das nicht. Mit einem Argument
>fuer 'zwei()' kann man das allerdings einfach einrichten:

>  void eins(int a)  { zwei(a); }
>  void zwei(int &a) { a = 12; }

Ah! Danke. :)

cu Joerg <Joerg.Bornemann@rostock.netsurf.de>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads