AutoSkill C++ BagInterface and MagicChangeBag Implementation
Implements a specific C++ data structure assignment involving an abstract Bag interface, a standard PlainBag, and a MagicChangeBag with unique insertion/removal logic.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/c-baginterface-and-magicchangebag-implementation" ~/.claude/skills/ecnu-icalk-autoskill-c-baginterface-and-magicchangebag-implementation && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/c-baginterface-and-magicchangebag-implementation/SKILL.mdsource content
C++ BagInterface and MagicChangeBag Implementation
Implements a specific C++ data structure assignment involving an abstract Bag interface, a standard PlainBag, and a MagicChangeBag with unique insertion/removal logic.
Prompt
Role & Objective
You are a C++ developer responsible for implementing a specific data structure assignment involving a Bag container.
Operational Rules & Constraints
- Language: Use C++.
- Templates: Use
for all classes to support any data type.template<typename T> - Class Structure:
- Create an abstract base class named
.BagInterface - Create a derived class named
.PlainBag - Create a derived class named
.MagicChangeBag
- Create an abstract base class named
- Interface Methods:
must define the following pure virtual methods:BagInterface
: Insert an item.insert(T item)
: Check if item is present (returns bool).contains(T item)
: Count copies of item (returns int).count(T item)
: Remove an item.remove(T item)
: Empty the bag.clear()
: Get item count (returns int).size()
: Check if empty (returns bool).is_empty()
: Check if full (returns bool).is_full()
- Capacity Constraint: The bag capacity is fixed at 20.
- PlainBag Logic:
- Use a
for storage.vector<T> - Implement standard container behavior for all methods.
- Use a
- MagicChangeBag Logic:
- Use a
for storage.vector<T> - Insert Behavior: When an item is inserted, it must "magically disappear" (the insert operation effectively does nothing, making the bag appear empty).
- Remove Behavior: When
is called, clear the bag and then add theremove(item)
being removed back into the bag (so the bag contains only that specific item).item - Query Behavior:
andcontains
should reflect the state where the bag appears empty after inserts.count
- Use a
Output
Generate the C++ code implementing the classes according to the rules above.
Triggers
- implement BagInterface PlainBag MagicChangeBag
- C++ bag assignment magic disappear
- design abstract Bag class with magic change bag
- MagicChangeBag insert disappear remove appear