N
none
I have extended a library class 'LibraryBase' which I cannot modify. 'LibraryBase' contains a const
function 'ConstFunction'. In my subclass 'LibrarySub' I am overriding 'ConstFunction'. But in this
function I now need to call a non const function.
But that gives an error and as I understand also violates the const principle.
But is there no way to call a non const function from a const function? Here is a basic example:
class Test {
public:
void testConst() const {
// this is a no go!
testNonConst();
}
void testNonConst() {
}
private:
};
int main(){
Test t;
t.testConst();
return 0;
}
function 'ConstFunction'. In my subclass 'LibrarySub' I am overriding 'ConstFunction'. But in this
function I now need to call a non const function.
But that gives an error and as I understand also violates the const principle.
But is there no way to call a non const function from a const function? Here is a basic example:
class Test {
public:
void testConst() const {
// this is a no go!
testNonConst();
}
void testNonConst() {
}
private:
};
int main(){
Test t;
t.testConst();
return 0;
}