c++ template specialization - linker error multiple definitions

十年热恋 提交于 2019-12-04 00:48:16

This function

Terminallog &Terminallog::operator<<(const char v[]) {
    std::cout << std::endl;
    this->indent();
    std::cout << v;
    return *this;
}

is not a template, but a regular member function. If this .h file is included in several .cpp filtes, it will cause the multiple definition error you're seeing. If you declare it inline, the compiler will allow the multiple definitions and your error should be fixed.

inline
Terminallog &Terminallog::operator<<(const char v[]) {
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!