所以我有静态成员我的头文件:C++类的静态成员
#ifndef PROFILE_MANAGER_H
#define PROFILE_MANAGER_H
#include <map>
#include <vector>
using namespace std;
using std::vector;
namespace Engine
{
class ProfileManager
{
private:
static map<const char*, vector<float>> profiles;
static map<const char*, vector<float>>::iterator it;
static pair<map<const char*, vector<float>>::iterator, bool> ret;
};
}
#endif
而且在我的cpp文件我有定义:
#include "ProfileManager.h"
namespace Engine
{
map<const char*, vector<float>> ProfileManager::profiles;
map<const char*, vector<float>>::iterator ProfileManager::it;
pair<map<const char*, vector<float>>::iterator, bool> ProfileManager::ret;
}
链接器总是抱怨的静态成员是即使我已经在cpp文件中定义了它们,也是无法解析的外部(LNK2001)。任何想法为什么?
我更惊讶*编译器*不会抱怨丢失的分号! –
更不用说重复使用右移运算符。 – WhozCraig
你确定你正在编译cpp文件? –