码迷,mamicode.com
首页 > 编程语言 > 详细

C++面向对象实践

时间:2019-07-07 21:31:28      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:std   span   pac   cout   实践   namespace   pre   ace   eth   

实践如下:

class Person{

private:
    int age;
    char name[25];
    int hight;

public:
    Person(int age, int hight, char* name);
    int getAge();
    char* getName();
    int getHight(){
        return hight;
    }
};
#include "Person.h"


Person::Person(int age, int hight, char* name1){
    Person::age = age;
    Person::hight = hight;
    Person::name = name1;
}

int Person::getAge(){
    return age;
}

char* Person::getName(){
    return name;
}
#include <iostream>

#include "Person.h"

using namespace std;

int main(){

    cout << "面向对象实践:" << endl;


    cout << "end." << endl;

    return 0;
}

 

C++面向对象实践

标签:std   span   pac   cout   实践   namespace   pre   ace   eth   

原文地址:https://www.cnblogs.com/do-your-best/p/11147888.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!