2012-05-08 1 views
0

VS 2010의 C++에서 간단한 파일 I/O 처리 프로그램을 실행하려고합니다. 그러나 실행하려고하면 오류가 발생합니다. fstream으로 할 수 있습니다. 이 프로그램은 매우 간단하며 2 개의 텍스트 파일을 열고 첫 번째 텍스트 파일을 사소한 변경으로 두 번째 텍스트 파일로 복사합니다. 나는 내가 올바른 논리를 가지고 있다고 확신하지만 내가 뭘 잘못하고 있는지 확신하지 못한다. 어떤 도움이라도 대단히 감사 할 것입니다. 감사.C++의 간단한 파일 처리 코드에서 막연한 오류가 발생했습니다.

#include<fstream> 
#include<iostream> 
#include<cstdlib> 

using namespace std; 

void file1(ifstream& in_stream, ofstream out_stream); 

int main() 
{ 
ifstream fin; 
ofstream fout; 
char name1[60]; 
cout<<"Enter the name of the input file: "<<endl; 
cin>>name1; 
fin.open(name1); 
if(fin.fail()) 
{ 
    cout<<"Failed to open Input file"<<endl; 
    exit(1); 
} 
else 
{ 
    cout<<"Input file opened successfully"<<endl; 
} 
char name2[60]; 
cout<<"Enter the name of the output file: "<<endl; 
cin>>name2; 
fout.open(name2); 
if(fout.fail()) 
{ 
    cout<<"Failed to open Output file"<<endl; 
    exit(1); 
} 
else 
{ 
    cout<<"Output file opened successfully"<<endl; 
} 
file1(fin, fout); 
fin.close(); 
fout.close(); 
return 0; 
} 

void file1(ifstream& in_stream, ofstream out_stream) 
{ 
char next; 
in_stream.get(next); 
while(!in_stream.eof()) 
{ 
    if(next=='A') 
    { 
     out_stream<<"ABC"; 
    } 
    else 
    { 
     out_stream<<next; 
    } 
    in_stream.get(next); 
} 
} 

이 내가 VS 2010가 발생하는 정확한 오류입니다 :

오류 1 오류 C2248 : '표준 : basic_ios < _Elem, _Traits> :: basic_ios' 여기 코드의 개인에 액세스 할 수 없습니다 멤버 클래스에 선언 '표준 : : basic_ios는 _Elem는 _Traits은> <'c : \ program에 files (86) \ 마이크로 소프트 비주얼 스튜디오 10.0 \ VC의 \ 포함 \ fstream 1116 1 파일

답변

4

out_stream 의미 값에 의해 전달되는 private 인 복사 생성자를 호출하려는 시도가 있습니다. 참조 번호 :

void file1(ifstream& in_stream, ofstream& out_stream);