C++相談室 part88
■ このスレッドは過去ログ倉庫に格納されています
0651デフォルトの名無しさん
2011/04/12(火) 00:27:52.91処理が同じconstメンバ関数と非constメンバ関数をもっとスマートに記述する方法ありますか?
class Hoge
{
public:
string & GetName() { return this->name; }
const string & GetName() const { return this->name; }
private:
string name;
};
「return this->name;」の部分がもっと複雑だったばあいの処理を一箇所にまとめたいんだけど・・・
■ このスレッドは過去ログ倉庫に格納されています