使用string,ostringstream等需要注意的事

    技术2025-06-09  30

    void SqList<T>::traverse( std::ostringstream &osstream ) const

     

    今天自己写了个模版类,需要在其中使用string,ostringstream等

    因为他们属于标准模板库,所以需要注意不管是函数的返回值还是参数,都必须加上std::

    或者干脆using namespace std;

     

    另外这些类的拷贝构造函数一般都是private的,所以返回值和参数类型一般为引用

     

     

    最新回复(0)