关于功能问题 [英] about functions question

查看:63
本文介绍了关于功能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试试吧:


def b():

...

a()

...


def a():

...

b()

...


b()

它不起作用。


是否有可能预售 - 在c ++中定义函数或者在主块之后放置函数代码




int a();

int b( );


int main()

{

....

a();

....

}


int a()

{

....

b();

....

}


int b()

{

....

a();

....

}


=)抱歉我的英文;)

解决方案

NoName schrieb:


我试试看:


def b():

...

a()

...


def a():

...

b()

...


b()

它不起作用。



它的工作原理。

def a():

print" a"

b()

def b():

打印" b"

打印#不打电话!

b()


但如果你真的打电话给b,你会创建一个无限循环。在所有

编程语言中,顺便说一句。


是否可以预定义函数,如c ++



No.


或放置功能代码

在主要块之后?



是。


10月25日凌晨2:28,NoName< zaz ... @ gmail.com写道:


我试试看:


def b():

。 ..

a()

...


def a():

.. 。

b()

...


b()

它不起作用。



确实如此。请发布完整的代码和错误消息,其他内容

错误,不是循环引用。


George


On Thu,2007年10月25日06:28:16 +0000,NoName写道:


我试试看:


def b():

...

a()

...


def a():

...

b()

...

b()

它不起作用。



你不工作是什么意思?在调用`b()`时,两个

函数都被定义,所以它应该工作。或者至少它不是你认为的那个问题。上面的代码,点都没有替换,

当然会永远地运行。直到达到堆栈限制。


Ciao,

Marc''BlackJack''Rintsch


I try it:

def b():
...
a()
...

def a():
...
b()
...

b()
it''s not work.

Is it possible pre-define function like in c++ or place functions code
after main block?

int a();
int b();

int main ()
{
....
a();
....
}

int a()
{
....
b();
....
}

int b()
{
....
a();
....
}

=) sorry for my eng;)

解决方案

NoName schrieb:

I try it:

def b():
...
a()
...

def a():
...
b()
...

b()
it''s not work.

It works.
def a():
print "a"
b()
def b():
print "b"
print a # not calling!
b()

But if you really call a in b, you create an endless loop. In all
programming languages, btw.

Is it possible pre-define function like in c++

No.

or place functions code
after main block?

Yes.


On Oct 25, 2:28 am, NoName <zaz...@gmail.comwrote:

I try it:

def b():
...
a()
...

def a():
...
b()
...

b()
it''s not work.

It sure does. Please post full code and error message, something else
is wrong, not the cyclic reference.

George


On Thu, 25 Oct 2007 06:28:16 +0000, NoName wrote:

I try it:

def b():
...
a()
...

def a():
...
b()
...

b()
it''s not work.

What do you mean by not working? At the time `b()` is called, both
functions are defined so it should working. Or at least it''s not the
problem you think it is. The code above, the dots replaced with nothing,
will of course run "forever" until the stack limit is reached.

Ciao,
Marc ''BlackJack'' Rintsch


这篇关于关于功能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆