2016-11-06 23 views
-2

プライベートな静的クラスメンバへの次のポインタの配列を作成するにはどうすればよいですか?これらの行を置くためにC++ - 静的なcharポインタの配列を初期化する

class Auth { 
private: 
    static char *attribs[3]; 
    attribs[0]="uid"; 
    attribs[1]="cn"; 
    attribs[2]=NULL; 
} 

私はどのように、どこにアイデアをしています... auth.h

+0

は、なぜあなたはこの –

+0

のためのstrdupを使用しているM.M @多くの試行のちょうど残り... – Pali

答えて

1

(何の.hで、何.CPPで?):で

class Auth { 
private: 
    static char *attribs[3]; 
}; 

auth.cpp:あなたがC++ 11へのアクセスを持っていると仮定すると

char* Auth::attribs[3] = { "uid", "cn", NULL }; 
+0

datの簡単な..私に恥!ありがとうございました! – Pali

1

、あなたはstd::stringを検討すべきであると代わりに、Cスタイルの配列のstd::vectorとCスタイルの文字列

#include <vector> 
#include <string> 

class Auth { 
    private: 
     static std::vector<std::string> attribs; 
}; 

std::vector<std::string> Auth:: attribs = {"uid", "cn"}; 
関連する問題