Is there any way you can include a function inside your .h file that is not int the base .h file ? In other words, the function is not in base .h file and it is not virtual, so you only create it inside .h file.
I get an error:
In file included from a4.cpp:7:0:
True_or_false.h: In member function ‘virtual void kk::True_or_false::print_all() const’:
True_or_false.h:79:29: error: passing ‘const kk::True_or_false’ as ‘this’ argument discards qualifiers [-fpermissive]
calculate_score();
^
compilation terminated due to -Wfatal-errors.
<builtin>: recipe for target 'a4' failed
make: *** [a4] Error 1]
Note: calculate_score() is a void function that wants to just cout in another constant function from base .h file.
So you mean changing the function to const will solve the proble or maybe I can include that void function in my main using an object that is the same for every other functions ?
Yes, if the problem is that you're calling calculate_score() from print_all() that will solve the problem. calculate_score() doesn't modify the object so there is no reason why it shouldn't be const.