Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2508578
  • 博文数量: 308
  • 博客积分: 5547
  • 博客等级: 大校
  • 技术积分: 3782
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-24 09:47
个人简介

hello world.

文章分类

全部博文(308)

分类: C/C++

2010-11-18 15:38:10

#include <iostream>
using namespace std;

class Student
{
    public:
    Student(int n,float s):num(n),score(s){}
    
    void change(int n,float s) const
    {
        num = n;
        score = s;
    }
    
    void display() const
    {
        cout << num << " " << score << endl;
    }
    
    private:
    mutable int num;
    mutable float score;
};

int main()
{
    const Student stud(101,78.5);
    stud.display();
    stud.change(101,80.5);
    stud.display();
    
    system("pause");
    return 0;
}


阅读(983) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~