c++ - How to initialize a static const set<string> in implementation file? -
my initialisation of static const set<string>
appears incorrect, i'd appreciate guidelines on this:
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]));
but yields error: error: conversion ‘const string* {aka const std::basic_string<char>*}’ non-scalar type ‘const std::set<std::basic_string<char> >’ requested
can tell me correct way initialise set?
take out =
. invoke constructor.
const set<string> obj::keywords (kw,kw + sizeof(kw)/sizeof(kw[0]));
Comments
Post a Comment