I am trying to create a Singleton class in C ++ with Xcode. This is really a base class, and I get a linker error that I don't understand. Can anyone help?
Here is the class header file:
#ifndef _NETWORK_H_
Here is the impl file:
#include "Network.h" Network* Network::instance() { if (!_instance) _instance = new Network(); return _instance; }
Here is the compiler error:
Undefined symbols for architecture x86_64: "Network::_instance", referenced from: Network::instance() in Network.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
source share