Skip to content

Latest commit

 

History

History
39 lines (28 loc) · 910 Bytes

File metadata and controls

39 lines (28 loc) · 910 Bytes

C++ Coding Standards

General Guidelines

  • 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.

File Organization

  • Header files should have include guards or #pragma once.
  • Source files should include only necessary headers.

Error Handling

  • Use exceptions for error handling where appropriate.
  • Prefer RAII for resource management.

Testing

  • Write unit tests for all classes and functions.
  • Use Google Test or Catch2 frameworks.

Example

#include <iostream>
#include <vector>

void PrintItems(const std::vector<std::string>& items) {
    for (const auto& item : items) {
        std::cout << item << std::endl;
    }
}