C++基础知识 – 继承和派生的实现
继承和派生的实现
分析:
父类 Father.h
#pragma once
#include
using namespace std;
class Father{
public:
Father(string name, int age);
~Father();
string getName() const;
int getAge() const;
string description() const;
private:
string name;//姓名
int age; //年龄
};
父类 Father.cpp
#include
#include "Father.h"
Father::Father(string name, int age){
this->name = name;
this->age = age;
}
Father::~
共有 0 条评论