Global function definition in header file – how to avoid duplicated symbol linkage error

Use the inline keyword.

inline std::ostream& operator<< (std::ostream& o, const error_code& e) {
    return o << "[" << e.hi << "," << e.lo << "]";
}

Leave a Comment