無法訪問 private 成員(在“std::basic_ios”類中聲明


error C2248: “std::basic_ios<_Elem,_Traits>::basic_ios”: 無法訪問 private 成員(在“std::basic_ios<_Elem,_Traits>”類中聲明)問題解決

原因好像是流對象是不允許複製,所以在傳給函數作爲參數是應該傳入引用,這樣就沒有問題了

ostream& operator<<(ostream out , myVector v)
{
	out<<"("<<v.x<<","<<v.y<<","<<v.z<<")"<<endl;
	return out ;
}

改成:

ostream& operator<<(ostream& out , myVector v)
{
out<<"("<<v.x<<","<<v.y<<","<<v.z<<")"<<endl;
return out ;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章