文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Class程序练习1

Class程序练习1

时间:2010-03-06  来源:hnrainll

#include <iostream>
#include <string>

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 <<m_name<<"           "<<m_age<<endl;
}

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
相关阅读 更多 +
排行榜 更多 +
边境检察最后区域手机版下载

边境检察最后区域手机版下载

角色扮演 下载
酋长你别跑手游下载

酋长你别跑手游下载

休闲益智 下载
心动漫画app下载官方版

心动漫画app下载官方版

浏览阅读 下载