C++类继承与多态代码实现
根据用户提供的类继承关系描述、数据成员定义、输入输出样例及参考主函数,生成符合要求的C++代码。包含构造函数、成员函数重写及输入合法性校验。
npx skills add ECNU-ICALK/AutoSkill --skill c-类继承与多态代码实现 --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 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++编程题
- Prompt
- Triggers
What does the C++类继承与多态代码实现 skill do?
根据用户提供的类继承关系描述、数据成员定义、输入输出样例及参考主函数,生成符合要求的C++代码。包含构造函数、成员函数重写及输入合法性校验。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill c-类继承与多态代码实现 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
