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

hello world.

文章分类

全部博文(308)

分类: C/C++

2010-11-18 15:42:38

#include <iostream>
using namespace std;

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

int main()
{
    Student stud(101,78.5);
    Student *p = &stud;
    p->display();
    p->change(101,80.5);
    p->display();
    
    system("pause");
    return 0;
}


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