Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4253255
  • 博文数量: 1148
  • 博客积分: 25453
  • 博客等级: 上将
  • 技术积分: 11949
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-06 21:14
文章分类

全部博文(1148)

文章存档

2012年(15)

2011年(1078)

2010年(58)

分类: C/C++

2011-04-19 19:56:29

                函数重载

定义:
      同名但是不同参数类型或者参数个数的函数,叫做函数重载

例如:
      void input();
      void input(char * name,int age);
      void input(CStudent * stu);


  1. #include <iostream.h>
  2. class CStudent
  3. {
  4.   public:
  5.     CStudent();  //重载函数
  6.    CStudent(char * name,int age);
  7.    CStudent(CStudent & student);

  8.  private:
  9.    char m_name[20];
  10.    int m_age;
  11. }

  1. void init()    //函数重载
  2. {
  3. ...
  4. }

  5. void init(CStudent student)
  6. {
  7. ...
  8. }









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