Skip to content
Back to skills

C Baginterface And Magicchangebag Implementation

ASecurity

Implements a specific C++ data structure assignment involving an abstract Bag interface, a standard PlainBag, and a MagicChangeBag with unique insertion/removal logic.

  • 581 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 30, 2026
educationc++

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill c-baginterface-and-magicchangebag-implementation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of C Baginterface And Magicchangebag Implementation?

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

Security grade badge for C Baginterface And Magicchangebag Implementation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-c-baginterface-and-magicchangebag-implementation/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-c-baginterface-and-magicchangebag-implementation)

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: "b9e7fd79-d1dd-495c-91dc-262fa1bceb13"
name: "C++ BagInterface and MagicChangeBag Implementation"
description: "Implements a specific C++ data structure assignment involving an abstract Bag interface, a standard PlainBag, and a MagicChangeBag with unique insertion/removal logic."
version: "0.1.0"
tags:
  - "C++"
  - "Data Structure"
  - "Bag"
  - "Template"
  - "Assignment"
triggers:
  - "implement BagInterface PlainBag MagicChangeBag"
  - "C++ bag assignment magic disappear"
  - "design abstract Bag class with magic change bag"
  - "MagicChangeBag insert disappear remove appear"
---

# 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
1. **Language**: Use C++.
2. **Templates**: Use `template<typename T>` for all classes to support any data type.
3. **Class Structure**:
   - Create an abstract base class named `BagInterface`.
   - Create a derived class named `PlainBag`.
   - Create a derived class named `MagicChangeBag`.
4. **Interface Methods**: `BagInterface` must define the following pure virtual methods:
   - `insert(T item)`: Insert an item.
   - `contains(T item)`: Check if item is present (returns bool).
   - `count(T item)`: Count copies of item (returns int).
   - `remove(T item)`: Remove an item.
   - `clear()`: Empty the bag.
   - `size()`: Get item count (returns int).
   - `is_empty()`: Check if empty (returns bool).
   - `is_full()`: Check if full (returns bool).
5. **Capacity Constraint**: The bag capacity is fixed at 20.
6. **PlainBag Logic**:
   - Use a `vector<T>` for storage.
   - Implement standard container behavior for all methods.
7. **MagicChangeBag Logic**:
   - Use a `vector<T>` for storage.
   - **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 `remove(item)` is called, clear the bag and then add the `item` being removed back into the bag (so the bag contains only that specific item).
   - **Query Behavior**: `contains` and `count` should reflect the state where the bag appears empty after inserts.

# 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

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.

Comments

Loading comments…

Newsletter

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