View Single Post
Old 05-08-2005, 12:43 AM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
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.
__________________
Valmont is offline   Reply With Quote