面试C++试题[14]

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 x1001 的 blog

             

              // 3)分配新的内存资源,并复制内容 // 3

       int length = strlen(other.m_data);    

       m_data = new char[length+1];         // 若能加 null 判断则更好

              strcpy(m_data, other.m_data);

             

              // 4)返回本对象的引用            // 3

              return *this;

}    

std::ostream& operator <<(std::ostream& os, const string& arg) //add by xie

{

  os<<arg.m_data;

  return os;  

}

 

int main()

本文关键:C++,林锐,面试试题
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top