agentsclimarketplace

C 类继承与多态代码实现

Skill ECNU-ICALK/AutoSkill/SkillBank/Users/chinese_gpt3.5_8_GLM4.7/c-类继承与多态代码实现

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

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

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.2 KB, 532 tokens by cl100k_base, as published. Nobody here has run it

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++编程题

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.