C++的流basic_streambuf

本文介绍了C++标准库中的流缓冲区类basic_streambuf的基本结构和功能,包括读写指针管理、缓冲区操作及同步刷新等关键方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 摘自: http://blog.youkuaiyun.com/linweixuan/archive/2006/09/09/1197233.aspx
不是个抽象类 , 但是他是 C++ 流的基类 . 它提供了基本的缓冲区管理 . 它包含六个缓存区指针 , 三个分别是读指针 ( 开头 , 结尾 , 当前 ), 另外三个是写指针 ( 开头 , 结尾 , 当前 )
 
    读开始指针                             当前读指针                                     读结尾指针
_M_gbegin                          _M_gnext                      _M_gend
         
         =========================================================    
              ^                                                      ^                                              ^
       _M_pbegin                          _M_pnext                      _M_pend
           写开始指针                             当前写指针                             写结尾指针
 
template < class _CharT , class _Traits >
class basic_streambuf
{
  friend class basic_istream < _CharT , _Traits >;
  friend class basic_ostream < _CharT , _Traits >;
public :                         // Typedefs.
  typedef _CharT                    char_type ;
  typedef typename _Traits :: int_type        int_type ;
  typedef typename _Traits :: pos_type     pos_type ;
  typedef typename _Traits :: off_type       off_type ;
  typedef _Traits                      traits_type ;
 
public :                         // Destructor.
  virtual ~ basic_streambuf () {}
 
public :                         // Locale-related functions.
  locale pubimbue ( const locale & __loc ) {
    this -> imbue ( __loc );
    locale __tmp = _M_locale ;
    _M_locale = __loc ;
    return __tmp ;
 }
  locale getloc () const { return _M_locale ; }
 
public :                         // Buffer management.
  // 设置缓冲区和长度
  basic_streambuf * pubsetbuf ( char_type * __s , streamsize __n )
    { return this -> setbuf ( __s , __n ); }
 
 // 设置缓冲区偏移量 , 简单调用 seekoff() 函数
  pos_type pubseekoff ( off_type __offset , ios_base :: seekdir __way ,
                      ios_base :: openmode __mod = ios_base :: in | ios_base :: out )
    { return this -> seekoff ( __offset , __way , __mod ); }
// 设置缓冲区位置 , 简单调用 seekpos() 函数
  pos_type pubseekpos ( pos_type __sp ,
                      ios_base :: openmode __mod = ios_base :: in | ios_base :: out )
    { return this -> seekpos ( __sp , __mod ); }
 
// 放置缓冲区同步 , 简单调用 sync() 函数
  int pubsync () { return this -> sync (); }
 
public :                       
  // 读取字符的公共成员函数  
 
// 比较当前指针和结尾指针 , 如果在结尾之前返回剩下的缓冲区大小 . 否则调用 showmanyc() 函数
  streamsize in_avail () {
    return _M_gnext < _M_gend ? _M_gend - _M_gnext : this -> showmanyc ();
 }
 
 // 移动到下一个字符 , 并返回下一字符
  int_type snextc () {
    return _M_gend - _M_gnext > 1 ? _Traits :: to_int_type (*++ _M_gnext )
                                  : this -> _M_snextc_aux ();
 }
 
 // 移动到下一个字符 , 并返回当前字符
  int_type sbumpc () {
    return _M_gnext < _M_gend ? _Traits :: to_int_type (* _M_gnext ++)
                              : this -> uflow ();
 }
 
// 并返回当前字符 , 指针不移动到
  int_type sgetc () {
    return _M_gnext < _M_gend ? _Traits :: to_int_type (* _M_gnext )
                              : this -> underflow ();
 }
   
 // 获取 n 个字符串到参数 __s
  streamsize sgetn ( char_type * __s , streamsize __n )
    { return this -> xsgetn ( __s , __n ); }
 
 // 比较当前前一个字符是否与参数 __c 相等 , 相等则返回 , 移动当前指针 当前前一个字符并返回
  int_type sputbackc ( char_type __c ) {
    return _M_gbegin < _M_gnext && _Traits :: eq ( __c , *( _M_gnext - 1))
      ? _Traits :: to_int_type (*-- _M_gnext )
      : this -> pbackfail ( _Traits :: to_int_type ( __c ));
 }
 
 // 移动当前指针 当前前一个字符并返回
  int_type sungetc () {
    return _M_gbegin < _M_gnext
      ? _Traits :: to_int_type (*-- _M_gnext )
      : this -> pbackfail ();
 }
 
public :                        
// 公共写字符成员函数
 
 // 写入一个字符 ,
  int_type sputc ( char_type __c ) {
    return _M_pnext < _M_pend
      ? _Traits :: to_int_type (* _M_pnext ++ = __c )
      : this -> overflow ( _Traits :: to_int_type ( __c ));
 }
 
 // 写入长度为 n 的字串
  streamsize sputn ( const char_type * __s , streamsize __n )
    { return this -> xsputn ( __s , __n ); }
 
 // 扩展写 n 个字符函数
  streamsize _M_sputnc ( char_type __c , streamsize __n )
    { return this -> _M_xsputnc ( __c , __n ); }
 
public :                        
// 线程安全的锁
 _STL_mutex_lock _M_lock ;
 
protected :                     
// 缺省构造函数
  basic_streambuf ()
    : _M_gbegin (0), _M_gnext (0), _M_gend (0),
      _M_pbegin (0), _M_pnext (0), _M_pend (0),
      _M_locale ()
    {
      _M_lock ._M_initialize();
    }
 
protected :                     
// 保护的获取读指针的成员函数
  char_type * eback () const { return _M_gbegin ; }   // 开头读指针
  char_type * gptr ()  const { return _M_gnext ; }   // 当前读指针
  char_type * egptr () const { return _M_gend ; }   // 结尾读指针
 
 // 将读指针向移动 n 个字符
  void gbump ( int __n ) { _M_gnext += __n ; }
 
 // 从新设置读的三个指针
  void setg ( char_type * __gbegin , char_type * __gnext , char_type * __gend ) {
    _M_gbegin = __gbegin ;
    _M_gnext  = __gnext ;
    _M_gend    = __gend ;
 }
 
protected :                     
// 保护的获取写指针的成员函数
        
  char_type * pbase () const { return _M_pbegin ; } // 开头读指针
  char_type * pptr ()  const { return _M_pnext ; }  // 当前读指针
  char_type * epptr () const { return _M_pend ; }   // 结尾读指针
 
 // 将写指针向移动 n 个字符
  void pbump ( int __n ) { _M_pnext += __n ; }
 
// 从新设置读的三个指针
  void setp ( char_type * __pbegin , char_type * __pend ) {
    _M_pbegin = __pbegin ;
    _M_pnext  = __pbegin ;
    _M_pend    = __pend ;
 } 
 
protected :                     
// 本地化虚函数
  virtual void imbue ( const locale &) {}
 
protected :                     
// 内存管理 虚函数 , 当前置返回自己 this
  virtual basic_streambuf * setbuf ( char_type *, streamsize )
    { return this ; }
 
 
 // 通过一个整型偏移值 , 改变流的位置 . 该函数这里什么读没作 , 只返回 -1, 在子类中重载
  virtual pos_type seekoff ( off_type , ios_base :: seekdir ,
                           ios_base :: openmode = ios_base :: in | ios_base :: out )
    { return pos_type (-1); }
 
// 通过前面获取流位置 , 改变流的位置 . 该函数这里什么读没作 , 只返回 -1, 在子类中重载
  virtual pos_type
  seekpos ( pos_type , ios_base :: openmode = ios_base :: in | ios_base :: out )
    { return pos_type (-1); }
 
 // 同步 ( 刷新 ). 缓冲区 . 所有的子类中重载
  virtual int sync () { return 0; }
 
protected :                     
 // 返回在在抵达文件结尾更低级可以读取字符数 . (-1 是特定值 , 意味着 underflow 将失败 .)
// 函数在子类中重载
  virtual streamsize showmanyc ()
    { return 0; }
 
 // 读取 n 的字符 . 返回可读取的字符数
  virtual streamsize xsgetn ( char_type * __s , streamsize __n );
 
 // 当没有读取的位置时调用 . : gptr() 返回为空时或者 gptr() >= egptr().
  virtual int_type underflow ()
    { return _Traits :: eof (); }
 
 // 类似 underflow(), 但是使用在 unbuffered 输入 .
  virtual int_type uflow () {
    return _Traits :: eq_int_type ( this -> underflow (), _Traits :: eof ())
      ? _Traits :: eof ()
      : _Traits :: to_int_type (* _M_gnext ++);
 }
 
// 当没有放置的位置时调用 . : gptr() 返回为空时或者 gptr() == eback().
  virtual int_type pbackfail ( int_type __c = _Traits :: eof ())
    { return _Traits :: eof (); }
 
protected :              
 // n 字符 , 返回写的字符数
  virtual streamsize xsputn ( const char_type * __s , streamsize __n );
 
// 当没有写位置时调用
  virtual int_type overflow ( int_type = _Traits :: eof ())
    { return _Traits :: eof (); }
 
private :                       
  char_type * _M_gbegin ;         // get 区的开始指针
  char_type * _M_gnext ;          // get 区的当前指针
  char_type * _M_gend ;           // get 区的结尾指针
 
  char_type * _M_pbegin ;         // put 区的开始指针
  char_type * _M_pnext ;          // put 区的当前指针
  char_type * _M_pend ;           // put 区的结尾指针
 
  locale _M_locale ;             // The streambuf's locale object
};
 
 
||=== Build file: "no target" in "no project" (compiler: unknown) ===| E:\C++\2\main.cpp||In function 'int main()':| E:\C++\2\main.cpp|11|error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and '<unresolved overloaded function type>')| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|120|note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|120|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'}| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|124|note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|124|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|131|note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|131|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|168|note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|168|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool&'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|172|note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|172|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int&'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|175|note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|175|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int&'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|179|note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|179|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int&'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|182|note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|182|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int&'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|186|note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|186|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int&'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|190|note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|190|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int&'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|195|note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|195|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int&'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|199|note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|199|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int&'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|214|note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|214|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float&'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|218|note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|218|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double&'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|222|note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|222|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double&'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|235|note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|235|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'void*&'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|259|note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|259|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_istream<char>::__streambuf_type*' {aka 'std::basic_streambuf<char>*'}| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\bits\basic_string.tcc|1465|note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\bits\basic_string.tcc|1465|note: template argument deduction/substitution failed:| E:\C++\2\main.cpp|11|note: couldn't deduce template parameter '_Alloc'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\bits\istream.tcc|931|note: candidate: 'std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT&) [with _CharT = char; _Traits = std::char_traits<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\bits\istream.tcc|931|note: no known conversion for argument 2 from '<unresolved overloaded function type>' to 'char&'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|756|note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char&)'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|756|note: template argument deduction/substitution failed:| E:\C++\2\main.cpp|11|note: cannot convert 'std::endl' (type '<unresolved overloaded function type>') to type 'unsigned char&'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|761|note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char&)'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|761|note: template argument deduction/substitution failed:| E:\C++\2\main.cpp|11|note: cannot convert 'std::endl' (type '<unresolved overloaded function type>') to type 'signed char&'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|799|note: candidate: 'std::basic_istream<_CharT2, _Traits2>& std::operator>>(std::basic_istream<_CharT2, _Traits2>&, _CharT2*) [with _CharT2 = char; _Traits2 = std::char_traits<char>; _CharT = char; _Traits = std::char_traits<char>]'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|799|note: no known conversion for argument 2 from '<unresolved overloaded function type>' to 'char*'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|803|note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char*)'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|803|note: template argument deduction/substitution failed:| E:\C++\2\main.cpp|11|note: cannot convert 'std::endl' (type '<unresolved overloaded function type>') to type 'unsigned char*'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|808|note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char*)'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|808|note: template argument deduction/substitution failed:| E:\C++\2\main.cpp|11|note: cannot convert 'std::endl' (type '<unresolved overloaded function type>') to type 'signed char*'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|980|note: candidate: 'template<class _Istream, class _Tp> typename std::enable_if<std::__and_<std::__not_<std::is_lvalue_reference<_Tp> >, std::__is_convertible_to_basic_istream<_Istream>, std::__is_extractable<typename std::__is_convertible_to_basic_istream<_Tp>::__istream_type, _Tp&&, void> >::value, typename std::__is_convertible_to_basic_istream<_Tp>::__istream_type>::type std::operator>>(_Istream&&, _Tp&&)'| E:\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\istream|980|note: template argument deduction/substitution failed:| E:\C++\2\main.cpp|11|note: couldn't deduce template parameter '_Tp'| E:\C++\2\main.cpp|12|error: 'class cube' has no member named 'setchang'| E:\C++\2\main.cpp|13|error: 'class cube' has no member named 'getchang'| ||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===| 是什么意思,怎么解决
最新发布
07-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值