const_castの使い方 - アールメカブ

アールメカブ


const_castの使い方

Programming

例えばクラスでconst属性を与えた変数は

class MyMecabCpp{
public:
	char *str;
const MeCab::Node *node;
	MeCab::Tagger *tagger;// = MeCab::createTagger (str);
public:
		int setNode();
};

実行時の関数では次のように初期化してみた

int MyMecabCpp::setNode(){
 node =  const_cast<MeCab::Node *>  
       (tagger->parseToNode(str));// ()を忘れないこと
 CHECK(node);
}
 
Link: Programming(4982d) Programming_C(5433d)
Last-modified: 2008-01-28 (月) 09:31:04 (5930d)