Experiment with this code:
Code:
#include<iostream>
class student
{
private:
int id;
mutable int j;
public:
student(int id, int j) : id(id), j(j) {}
public:
void set(int i) const
{
j=i; // can modify
}
void print() const
{
std::cout<<id<<" "<<j;
}
};
int main()
{
const student s1(1,1);
s1.set(5);
s1.print();
std::cin.get();
return 0;
}
Next time, format your code decently so it becomes readable. Also add the code between code tags. In general, READ the sticky topic I posted in the link below:
[READ THIS FIRST] About the standard C++ forum.