我对 a 的初始化static const set<string>
似乎不正确,感谢您对此的指导:
obj.h
:
class obj
{
...
private:
static const set<string> keywords;
...
}
obj.cpp
:
const string kw[] = {"GTR","LTR","LEQ","GEQ","NEQ","SQRT","sqrt"};
const set<string> obj::keywords = (kw,kw + sizeof(kw)/sizeof(kw[0]));
但这会产生错误:
error: conversion from ‘const string* {aka const std::basic_string<char>*}’ to non-scalar type ‘const std::set<std::basic_string<char> >’ requested
有人能告诉我初始化这个集合的正确方法吗?