Здравствуйте
Есть VC++ 6.0
class CCfgSection
{
vector<CCfgKey> m_Keys;
string m_Name;
string m_Comment;
public:
...
BOOL SetValue (const string &Name, const string &Value, const string &Comment = string());
};
class CCfgData
{
...
BOOL SetValue(const string &Key, const string &Value, const string &Comment = string(), const string &Section = string());
const CCfgSection *GetSection(const string &Name...) const;
protected:
vector <CCfgSection> m_Sections;
};
Логика подсказывает, что CCfgData::GetSection должна быть const, но
далее внутри CCfgData::SetValue делаю:
CCfgSection *pSection = const_cast<CCfgSection *>(GetSection(...))
для того, чтобы вызвать: pSection->SetValue(Key, Value, Comment)
Вопрос состоит в том, что оправдано-ли использование const_cast, я начинающий "С++ писатель" и начитался в книжках, что применение
*_cast следствие неправильного дизайна.
Заранее благодарю
С уважением, Михаил
Добавлено форматирование, удалены лишние пробельные строки — Кодт