// in ClassA.h
static NSString *globalStr = @"HelloWorld";
@interface ClassA
...
@end
// in ClassB.h
#include "ClassA.h"
// in ClassB.m
...
NSLog(@"The global string: %@", globalStr);
...
In C++, "static" should mean the variable or function has a internal linkage.
But it is used to share the variable in this case, error will occur without the static keyword.
I'm confused, could someone tell me the concept behind?
Thanks!