ofstream 간 = 연산 방법..
-
2012년 7월 12일 목요일 오전 1:36
안녕하세요 6.0에서 2010으로 포팅작업 중에 궁금한 점이 있어 올립니다.
#include<fstream>
using namespace std;.
.
ofstream file1;
ofstream file2;
file1 = file2;이런 코드에서
1>c:\program files\microsoft visual studio 10.0\vc\include\ostream(604): error C2249: 'std::basic_ios<_Elem,_Traits>::operator =' : private 멤버(가상 기본 'std::basic_ios<_Elem,_Traits>'에서 선언한)에 액세스할 수 있는 경로가 없습니다.
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 10.0\vc\include\ios(177) : 'std::basic_ios<_Elem,_Traits>::operator =' 선언을 참조하십시오.
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> 이 진단은 컴파일러 생성 함수 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator =(const std::basic_ostream<_Elem,_Traits> &)'에서 수행되었습니다.
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1>이 경고를 뱉네요. ofstream 간 대입이 막혀있는것 같습니다.
사용 가능한 방법이 있을까요?
모든 응답
-
2012년 7월 12일 목요일 오전 5:35중재자
2010에서는 ofstream 클래스의 = 연산자가 참조 문법을 사용하도록 변경되었습니다. 대입이 아닌 참조를 위해서는
ofstream &file1 = file2;
이라고 하셔야 합니다.
- 답변으로 표시됨 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxd 2012년 7월 17일 화요일 오전 5:40

