作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
<分区>
我的类的头文件定义为:
namespace mip {
class CustomStatic {
public:
static const char* GetVersion();
};
}
类文件定义为:
#include "CustomStatic.h"
namespace mip {
static const char* GetVersion() {
return "hello";
}
}
我正在从我的主类访问这个静态函数
#include "CustomStatic.h"
#include <iostream>
using std::cout;
using mip::CustomStatic;
int main() {
const char *msg = mip::CustomStatic::GetVersion();
cout << "Version " << msg << "\n";
}
当我尝试使用-编译它时
g++ -std=c++11 -I CustomStatic.h MainApp.cpp CustomStatic.cpp
我得到的错误是:
Undefined symbols for architecture x86_64:
"mip::CustomStatic::GetVersion()", referenced from: _main in MainApp-feb286.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
我是一名优秀的程序员,十分优秀!