내가 로케일 측면의 사용과 문자열로 wstring의 변환을 시도하고를 보호하지만, 나는 다음과 같은 오류에 붙어있어 :'가상 문자의 표준 : CTYPE <wchar_t> :: do_narrow (wchar_t를, 문자) CONST는'
test_facet.cpp: In function ‘int main()’:
test_facet.cpp:14: error: invalid initialization of reference of type ‘std::ctype<wchar_t>&’ from expression of type ‘const std::ctype<wchar_t>’
/usr/include/c++/4.4/bits/locale_facets.h:1430: error: ‘virtual char std::ctype<wchar_t>::do_narrow(wchar_t, char) const’ is protected
test_facet.cpp:16: error: within this context
출처 :
이#include <iostream>
#include <string>
#include <locale>
#include <algorithm>
using namespace std;
int main()
{
locale loc("");
std::wstring Str = L"ěščřžýáíé";
std::string Str2;
ctype<wchar_t> &ct = std::use_facet<std::ctype<wchar_t> >(loc);
for(std::wstring::const_iterator It = Str.begin(); It < Str.end(); ++It)
ct.do_narrow(*It, 'X');
std::cout << Str2 <<std::endl;
}
누군가가 말해 수, 내가 무슨 일을 dooing 무엇입니까?
감사합니다.
답장을 보내 주셔서 감사합니다. 어떻게 든 ctype의 모든 공용 회원을 놓쳤으며 보호 된 사람 만 보았습니다. – Trakhan