P
pit3k
How can I call non-const member function of a member of a class in one of
it's const qualified member function so that a compiler won't complain?
Here's the code:
bool otl_stream::eof();
class MyClass {
otl_stream m_otl_stream;
public:
bool is_valid() const {
return !m_otl_stream.eof();
}
};
The problem is the otl_stream::eof() function is not const qualified,
although it does not change the state of the object (the prototype of this
function is beyond my control).
I want to call it in my MyClass::is_valid() method which is const qualified.
How do I do this, without declaring m_otl_stream member as mutable?
it's const qualified member function so that a compiler won't complain?
Here's the code:
bool otl_stream::eof();
class MyClass {
otl_stream m_otl_stream;
public:
bool is_valid() const {
return !m_otl_stream.eof();
}
};
The problem is the otl_stream::eof() function is not const qualified,
although it does not change the state of the object (the prototype of this
function is beyond my control).
I want to call it in my MyClass::is_valid() method which is const qualified.
How do I do this, without declaring m_otl_stream member as mutable?