Production-grade skill for C++ fundamentals. Covers variables, data types, operators, control flow, functions, and program structure. Foundation for all C++ development.
Provides C++ fundamentals covering variables, operators, control flow, and functions. Use when users need help with basic C++ syntax, writing simple programs, or debugging compilation errors like undeclared identifiers or missing semicolons.
/plugin marketplace add pluginagentmarketplace/custom-plugin-cpp/plugin install cpp@pluginagentmarketplace-cppThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/config.yamlassets/schema.jsonreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyProduction-Grade Learning Skill | Foundation Building
Master the essential building blocks of C++ programming.
#include <iostream>
#include <cstdint> // Fixed-width integers
int main() {
// ─────────────────────────────────────────────────
// Integer Types (with guaranteed sizes)
// ─────────────────────────────────────────────────
int8_t tiny = 127; // 1 byte, -128 to 127
int16_t small = 32767; // 2 bytes
int32_t normal = 2147483647; // 4 bytes
int64_t large = 9223372036854775807; // 8 bytes
// Unsigned variants
uint8_t ubyte = 255; // 0 to 255
uint32_t ucount = 4294967295; // 0 to 4B
// ─────────────────────────────────────────────────
// Floating Point
// ─────────────────────────────────────────────────
float f = 3.14f; // ~7 decimal digits
double d = 3.14159265358979; // ~15 decimal digits
// ─────────────────────────────────────────────────
// Character & Boolean
// ─────────────────────────────────────────────────
char c = 'A'; // ASCII character
bool b = true; // true or false
// ─────────────────────────────────────────────────
// Modern C++ Initialization (prefer brace init)
// ─────────────────────────────────────────────────
int x{42}; // Brace initialization
auto y = 3.14; // Type deduction (double)
auto z{10}; // int
return 0;
}
| Category | Operators | Example |
|---|---|---|
| Arithmetic | + - * / % | 10 / 3 = 3 |
| Comparison | == != < > <= >= | 5 == 5 → true |
| Logical | && || ! | true && false → false |
| Bitwise | & | ^ ~ << >> | 0xFF & 0x0F → 0x0F |
| Assignment | = += -= *= /= | x += 5 |
| Increment | ++ -- | ++i (prefer prefix) |
// ─────────────────────────────────────────────────────
// Conditionals
// ─────────────────────────────────────────────────────
if (score >= 90) {
grade = 'A';
} else if (score >= 80) {
grade = 'B';
} else {
grade = 'F';
}
// Switch with C++17 init
switch (int x = getValue(); x) {
case 1: std::cout << "One\n"; break;
case 2: std::cout << "Two\n"; break;
default: std::cout << "Other\n"; break;
}
// ─────────────────────────────────────────────────────
// Loops
// ─────────────────────────────────────────────────────
// For loop (prefer prefix ++)
for (int i = 0; i < n; ++i) { }
// Range-based for (C++11)
for (const auto& item : container) { }
// While
while (condition) { }
// Do-while (runs at least once)
do { } while (condition);
// ─────────────────────────────────────────────────────
// Function declaration
// ─────────────────────────────────────────────────────
int add(int a, int b); // Declaration
void greet(std::string_view name); // string_view for efficiency
// ─────────────────────────────────────────────────────
// Definition with default parameter
// ─────────────────────────────────────────────────────
int add(int a, int b) {
return a + b;
}
void greet(std::string_view name = "World") {
std::cout << "Hello, " << name << "!\n";
}
// ─────────────────────────────────────────────────────
// Pass by reference (for modification or large objects)
// ─────────────────────────────────────────────────────
void increment(int& value) {
++value;
}
void process(const std::vector<int>& data) { // const ref for read-only
for (int x : data) { /* ... */ }
}
// ─────────────────────────────────────────────────────
// Function overloading
// ─────────────────────────────────────────────────────
int max(int a, int b) { return (a > b) ? a : b; }
double max(double a, double b) { return (a > b) ? a : b; }
| Error | Cause | Fix |
|---|---|---|
undefined reference | Missing function definition | Add function body |
expected ';' | Missing semicolon | Check previous line |
undeclared identifier | Variable not declared | Declare before use |
narrowing conversion | Data loss in brace init | Use explicit cast |
Compilation error?
├── "undefined reference"
│ └── Function declared but not defined → Add definition
├── "expected ';'"
│ └── Missing semicolon → Check line above error
├── "undeclared identifier"
│ └── Variable not in scope → Declare or check spelling
└── "no matching function"
└── Wrong argument types → Match function signature
#include <cassert>
void test_basics() {
// Test integer operations
assert(add(2, 3) == 5);
assert(add(-1, 1) == 0);
// Test floating point (with tolerance)
constexpr double epsilon = 1e-9;
assert(std::abs(calculateArea(2.0) - 12.566370614) < epsilon);
// Test boolean logic
assert((true && false) == false);
assert((true || false) == true);
std::cout << "All tests passed!\n";
}
Week 1: Foundation
├── Day 1-2: Variables & data types
├── Day 3-4: Operators
├── Day 5-6: Control flow
└── Day 7: Practice exercises
Week 2: Functions & Arrays
├── Day 1-2: Functions basics
├── Day 3-4: Arrays & pointers
├── Day 5-6: String handling
└── Day 7: Mini project
C++ Plugin v3.0.0 - Production-Grade Learning Skill
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.