This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我在一个函数中已经定义过,并且想在另一个函数中引用,此时说我未定义此变量,为啥。
变量在函数内部定义,那就是局部变量,你需要在另外的函数中也调用的话,需要定义成全局变量,不能在函数内部定义。
您好,我试着使用static,public const在函数内部定义,但还是无法在另一个函数中使用,仍然说我未定义。
不管你怎么定义,在函数内定义就是局部变量,无法在另一个函数中使用。
你是同一个变量需要在两个函数中使用的话,就不能在函数内部定义,需要在外部定义成全局变量。