开发者

ld: duplicate symbol _x in /users/.... ERROR

I have 2 different classes but same primitive type declaration as you see below

int x = 0;
- (void)viewDidLoad{
[super viewDidLoad];
}

if I change one of them name "x" to "y" there is no error? WHY? seperate classes same variable开发者_JS百科 whats the problem???


That's because the variable x is shared among classes. I think (but never tried) if you declare extern int x in another file, you could share the x variable.

Try static int x = 0. In general, always declare an internal class variable as static unless you want to share it with another file.


I meet the question. As Says , because the variable x is shared among classes. Modify the variable x to another name.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜