C++ templates and friends, linker error

后端 未结 1 2002
無奈伤痛
無奈伤痛 2021-01-27 00:41

Why does the following code not compile (linker error, unresolved external symbol, class std::basic_ostream > & __cdecl

相关标签:
1条回答
  • 2021-01-27 01:40

    This line:

    friend std::ostream& operator<<(std::ostream& Stream, const Class& Op);
    

    Should be:

    template <class T> friend std::ostream& operator<<(std::ostream& Stream, const Class<T>& Op);
    
    0 讨论(0)
提交回复
热议问题