#include using namespace std; class const_members { const int i; const int j; public: const_members(int initial_i, int initial_j): i(initial_i), j(initial_j){ //++i or ++j would not compile here f(); } ~const_members() { //--j or --i would not compile here f(); } void f() {} //a non-const member function }; class obj { int i; int j; public: obj(int initial_i, int initial_j): i(initial_i), j(initial_j) { ++i; ++j; f(); } ~obj() {f(); --j; --i;} void f() {} //a non-const member function }; int main() { const_members o1(30, 40); o1.f(); //will compile: o1 is not const object const obj o2(10, 20); //o2.f(); //won't compile: o2 is a const object return EXIT_SUCCESS; }