When i write simple C++ code in X-code, it shows Linker Error.
Undefined symbols for architecture x86_64: "Emp::id", referenced from: Emp::Emp() in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
#include <iostream>
using namespace std;
class Emp
{
public:
static int id;
int sal;
Emp()
{
Emp::id =10; // When i comment this line its working fine.
};
};
int main(int argc, const char * argv[])
{
Emp Ram;
cout << Ram.sal ;
return 0;
}