实践如下:
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; }
原文地址:https://www.cnblogs.com/do-your-best/p/11147888.html
时间: 2024-10-06 14:38:57