c 封装类,模范类

来源:互联网 发布:mac中没有 hosts文件 编辑:程序博客网 时间:2024/04/26 06:11
#include "stdafx.h"
#include "stdio.h"
#include "string.h"

struct peple
{
    char name[20];
    int age;
    
    void chushi(char * _name,int _age)
    {
       strcpy(name,_name);
       age=_age;
    }

    void sayHello()
    {
        printf("我是%s,我今年%d\n",name,age);
    }
};

int main(int argc, char* argv[])
{
     struct peple student;
        
        student.chushi("张三",20);

        student.sayHello();

    return 0;
}

0 0
原创粉丝点击