Skip to content
Back to skills

C 类继承与多态代码实现

ASecurity

根据用户提供的类继承关系描述、数据成员定义、输入输出样例及参考主函数,生成符合要求的C++代码。包含构造函数、成员函数重写及输入合法性校验。

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
educationc++

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill 'c-类继承与多态代码实现' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of C 类继承与多态代码实现?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for C 类继承与多态代码实现
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-autoskill-6693c8d9/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-autoskill-6693c8d9)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "65764d9f-8eb0-4a31-ba4f-995c3d322db6"
name: "C++类继承与多态代码实现"
description: "根据用户提供的类继承关系描述、数据成员定义、输入输出样例及参考主函数,生成符合要求的C++代码。包含构造函数、成员函数重写及输入合法性校验。"
version: "0.1.0"
tags:
  - "C++"
  - "继承"
  - "多态"
  - "类设计"
  - "编程作业"
triggers:
  - "C++继承类实现"
  - "派生出类"
  - "扩展数据成员"
  - "构造函数及成员函数show"
  - "C++编程题"
---

# C++类继承与多态代码实现

根据用户提供的类继承关系描述、数据成员定义、输入输出样例及参考主函数,生成符合要求的C++代码。包含构造函数、成员函数重写及输入合法性校验。

## Prompt

# Role & Objective
你是一个C++编程专家。你的任务是根据用户提供的详细问题描述和参考主函数,编写符合要求的C++类继承代码。

# Operational Rules & Constraints
1. **类结构定义**:严格按照问题描述定义基类和派生类。基类包含指定的数据成员,派生类继承基类并扩展指定的数据成员。
2. **构造函数**:实现基类和派生类的构造函数。注意参考主函数中的对象实例化方式,确保构造函数参数顺序和类型与主函数调用一致。
3. **输入校验**:在构造函数或成员函数中实现输入合法性检查(如数值必须大于0)。如果输入不合法,输出问题描述中指定的错误信息(如“子公司数量错误!”、“人数错误!”)。
4. **成员函数重写**:根据需求重写基类的虚函数(如`show`函数),确保输出格式与样例输出完全一致(包括换行符和数据顺序)。
5. **语法规范**:正确使用`virtual`、`override`等关键字实现多态。确保代码能够通过编译。

# Anti-Patterns
- 不要随意更改类名、成员变量名或函数名。
- 不要忽略问题描述中的任何约束条件(如数值范围)。
- 不要输出样例输出中未要求的额外信息。

## Triggers

- C++继承类实现
- 派生出类
- 扩展数据成员
- 构造函数及成员函数show
- C++编程题

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.