- Follow the Google C++ Style Guide as a base.
- Use 4 spaces per indentation level.
- Use meaningful variable, function, and class names.
- Write comments and documentation for all public APIs.
- Prefer smart pointers over raw pointers.
- Avoid using namespace in headers.
- Use const wherever possible.
- Header files should have include guards or #pragma once.
- Source files should include only necessary headers.
- Use exceptions for error handling where appropriate.
- Prefer RAII for resource management.
- Write unit tests for all classes and functions.
- Use Google Test or Catch2 frameworks.
#include <iostream>
#include <vector>
void PrintItems(const std::vector<std::string>& items) {
for (const auto& item : items) {
std::cout << item << std::endl;
}
}