C++ 建造dame期间的CTYPE问题
我正在努力建立一个女人。环境详情: GCC-GCC版本4.4.2(GCC) ANTLR-ANTLR解析器生成器版本2.7.2 当我试图编译以下代码段时:C++ 建造dame期间的CTYPE问题,c++,ctype,C++,Ctype,我正在努力建立一个女人。环境详情: GCC-GCC版本4.4.2(GCC) ANTLR-ANTLR解析器生成器版本2.7.2 当我试图编译以下代码段时: #include <functional> #include <iomanip> struct compare_without_case_char : public std::binary_function<char, char, bool> { const std::ctype<c
#include <functional>
#include <iomanip>
struct compare_without_case_char : public std::binary_function<char, char, bool>
{
const std::ctype<char>& ct ;
compare_without_case_char (const std::ctype<char>& c = std::use_facet<std::ctype<char> > (std::locale::classic()))
: ct(c) {}
bool operator() (char x, char y) const
{
return (ct.toupper(x) == ct.toupper(y)) ;
}
} ;
#包括
#包括
结构比较\u不带\u case\u char:public std::binary\u函数
{
const std::ctype&ct;
比较没有大小写字符的字符(const std::ctype&c=std::use_facet(std::locale::classic())
:ct(c){}
布尔运算符()(字符x,字符y)常量
{
返回值(ct.toupper(x)=ct.toupper(y));
}
} ;
出现以下错误:
test_ctype.cpp: In member function 'bool compare_without_case_char::operator()(char, char) const':
test_ctype.cpp:16: error: invalid use of incomplete type 'const struct std::ctype<char>'
/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/bits/localefwd.h:115: error: declaration of 'const struct std::ctype<char>'
test_ctype.cpp:16: error: invalid use of incomplete type 'const struct std::ctype<char>'
/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/bits/localefwd.h:115: error: declaration of 'const struct std::ctype<char>'
In file included from /storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/bits/locale_classes.h:809,
from /storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/bits/ios_base.h:43,
from /storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/iomanip:42,
from test_ctype.cpp:2:
/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/bits/locale_classes.tcc: In function 'const _Facet& std::use_facet(const std::locale&) [with _Facet = std::ctype<char>]':
test_ctype.cpp:11: instantiated from here
/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/bits/locale_classes.tcc:107: error: incomplete type 'std::ctype<char>' used in nested name specifier
/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/bits/locale_classes.tcc:112: error: cannot dynamic_cast '* *(__facets + ((unsigned int)(((unsigned int)__i) * 4u)))' (of type 'const class std::locale::facet') to type 'const struct std::ctype<char>&' (target is not pointer or reference to complete type)
test_ctype.cpp:在成员函数'bool compare_without_case_char::operator()(char,char)const'中:
test_ctype.cpp:16:错误:无效使用不完整的类型“const struct std::ctype”
/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_发布/gcc-4.4.2_构建/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../../include/c++/4.4.2/bits/localefwd.h:115:错误:“const struct std::ctype”声明
test_ctype.cpp:16:错误:无效使用不完整的类型“const struct std::ctype”
/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_发布/gcc-4.4.2_构建/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../../include/c++/4.4.2/bits/localefwd.h:115:错误:“const struct std::ctype”声明
在/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/bits/locale_classes.h:809中包含的文件中,
从/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../../../include/c++/4.4.2/bits/ios_base.h:43,
从/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../../../include/c++/4.4.2/iomanip:42,
从测试类型cpp:2:
/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_发布/gcc-4.4.2_构建/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../../../../c++/4.4.2/bits/locale_classes.tcc:在函数“const-Facet&std::use_Facet(const std::locale&”)[with-Facet=std::ctype]:
test_ctype.cpp:11:从此处实例化
/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_发布/gcc-4.4.2_构建/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../../../../include/c++/4.4.2/bits/locale_类。tcc:107:错误:嵌套名称说明符中使用的类型“std::ctype”不完整
/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_发布/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/bits/locale_类。tcc:112:错误:无法将“**”(((无符号int)((无符号int)((无符号int)u i)*4u))”)(const class::locale::std)类型的)转换为“**”(constd::locale::sect std::std::structype)std::struct类型)(目标不是完整类型的指针或引用)
真正的问题是什么以及我如何解决它。
当做
Anand Kumar Keshri这里唯一的问题是编译器无法找到
std::ctype
。您必须包含包含它的文件:
#include <locale>
#包括
如果您在functional和iomanipThanks.中没有ctype,请尝试#包括
,以获得您的支持。