Skip to content

SF.5: Add recommendation, that a .cpp file should include the .h file(s) that defines its interface at first. #366

@ksdd

Description

@ksdd

Including the interface defining header(s) at first ensures, that the header(s) are self-sufficient. Example:

// foo.h
int mean(const std::vector v);

// foo.cpp - bad include order

include

include <foo.h>

Missing include of vector in foo.h is undiscovered until other users may stumble over it. By including foo.h first the implementer immediately encouters this problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions