submission.cpp: In function ‘int main()’:
submission.cpp:42:36: error: invalid initialization of non-const reference of type ‘std::basic_string::iterator& {aka gnu_cxx::normal_iterator >&}’ from an rvalue of type ‘std::basic_string::iterator {aka gnu_cxx::normal_iterator >}’
submission.cpp:14:8: error: in passing argument 1 of ‘std::string reverse1(std::basic_string::iterator&)’
에러메시지로 이것이 뜨고 컴파일 실패가 됩니다. 이것이 무슨 의미인지 모르겠네요ㅠ
정확히 무엇때문에 컴파일 오류가 생기는 건가요?
소스코드가 어렵지 않아 소스코드도 올립니다
#include<iostream>
#include<string>
using namespace std;
#define FOR(i,end) for(int i = 0; i < (end) ; ++i )
string reverse1(string::iterator& it )
{
char head = *it ;
it++ ;
if ( head == 'b' || head == 'w' )
return string(1,head) ;
string upperLeft = reverse1(it) ;
string upperRight = reverse1(it) ;
string lowerLeft = reverse1(it) ;
string lowerRight = reverse1(it) ;
return (string("x") + lowerLeft + lowerRight + upperLeft + upperRight );
}
int main()
{
int T ;
cin>>T;
string str ;
while(T--)
{
cin>>str ;
//string::iterator it ;
string ans = reverse1(str.begin());
cout<<ans<<endl;
}
return 0 ;
}
rkd628
쿼드트리 문제를 책을 보며 풀었습니다.
제출을 하였는데 , 계속해서
submission.cpp: In function ‘int main()’:::iterator& {aka gnu_cxx::normal_iterator >&}’ from an rvalue of type ‘std::basic_string::iterator {aka gnu_cxx::normal_iterator >}’::iterator&)’
submission.cpp:42:36: error: invalid initialization of non-const reference of type ‘std::basic_string
submission.cpp:14:8: error: in passing argument 1 of ‘std::string reverse1(std::basic_string
에러메시지로 이것이 뜨고 컴파일 실패가 됩니다. 이것이 무슨 의미인지 모르겠네요ㅠ
정확히 무엇때문에 컴파일 오류가 생기는 건가요?
소스코드가 어렵지 않아 소스코드도 올립니다
12년 전