Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1567902
  • 博文数量: 354
  • 博客积分: 8137
  • 博客等级: 中将
  • 技术积分: 5137
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-26 15:40
文章分类

全部博文(354)

文章存档

2010年(300)

2009年(54)

分类: C/C++

2010-03-06 13:25:54

#include
#include

using namespace std;
class CStudent
{
public:
        CStudent();
        CStudent(char  *name,int age);
        
        void initialize(char *name,int age);
        void output();
private:
         char m_name[20];
         int m_age;
        
};

CStudent::CStudent()
{
    strcpy(m_name,"blank");
    m_age = 0;
}

CStudent::CStudent (char *name,int age)
{
        strcpy(m_name,name);
        m_age = age;
}

void CStudent::initialize(char *name,int age)
{
             strcpy(m_name,name);
            m_age = age;  
}

void CStudent::output()
{
        cout <}

int main()
{
        CStudent stu1;
        stu1.output();

        CStudent stu2("peg",22);
        stu2.output();

        CStudent stu3;
        stu3.initialize("KEVIN",23);
        stu3.output();
       
       
        return 0;
}


                                              2010.03.06@kevin
阅读(467) | 评论(0) | 转发(0) |
0

上一篇:extern的使用

下一篇:Class例程之2指针

给主人留下些什么吧!~~