C++錯誤
1、錯誤描述
[cpp]
error C2248: “std::basic_ios<_Elem,_Traits>::basic_ios”: 無法訪問 private 成員(在“std::basic_ios<_Elem,_Traits>”類中聲明)
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
2、錯誤原因 www.2cto.com
代碼中通過傳值方式傳遞iostream對象,而非引用的方式。將傳遞改為引用傳遞即可。
3、錯誤常見出現情況
1)>>和<<操作符重載
friend istream& operator>>(istream& is,Type& c);
friend ostream& operator<<(ostream& os,const Type& c);
2)將iostream對象當做成員變量
[cpp]
class CDxfFile
{
protected:
std::istream& m_is; //istream used for reading
}