Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/152.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 尝试扩展ctype方面时出现未定义的引用错误_C++_Locale_Facet_Ctype - Fatal编程技术网

C++ 尝试扩展ctype方面时出现未定义的引用错误

C++ 尝试扩展ctype方面时出现未定义的引用错误,c++,locale,facet,ctype,C++,Locale,Facet,Ctype,我试图通过扩展ctype来创建一个自定义的ctype方面,但是不断出现未定义的引用错误 以下是再现错误的最小测试程序: #包括 使用名称空间std; 类my_ctype:公共ctype{ 公众: 显式my_ctype(大小\u t\u引用=0); 受保护的: 虚拟~my_ctype(); 受保护的: 虚拟布尔值是(掩码,字符类型)常数; 虚拟常量字符类型*do是(常量字符类型*低,常量字符类型*高,掩码*向量)常量; 虚拟常量字符类型*do\U扫描\U是(掩码\uu m,常量字符类型*\uu l

我试图通过扩展ctype来创建一个自定义的ctype方面,但是不断出现未定义的引用错误

以下是再现错误的最小测试程序:

#包括
使用名称空间std;
类my_ctype:公共ctype{
公众:
显式my_ctype(大小\u t\u引用=0);
受保护的:
虚拟~my_ctype();
受保护的:
虚拟布尔值是(掩码,字符类型)常数;
虚拟常量字符类型*do是(常量字符类型*低,常量字符类型*高,掩码*向量)常量;
虚拟常量字符类型*do\U扫描\U是(掩码\uu m,常量字符类型*\uu lo,常量字符类型*\uu hi)常量;
虚拟常量字符类型*不扫描(掩码、常量字符类型*低、常量字符类型*高)常量;
虚拟字符类型do toupper(字符类型c)常量;
虚拟常量char_type*do_toupper(char_type*\u lo,const char_type*\u hi)常量;
虚拟字符类型do TOLU tolower(字符类型c)常数;
虚拟常量char\u type*do\u tolower(char\u type*\u lo,const char\u type*\u hi)常量;
虚拟字符类型do_加宽(字符c)常量;
虚拟常量字符*do_加宽(常量字符*低,常量字符*高,字符类型*目的地)常量;
虚拟字符(字符类型c,字符故障)常量;
虚拟常量字符类型*do_窄(常量字符类型*低,常量字符类型*高,字符故障,字符*到)常量;
};
我的类型::我的类型(大小)
my_ctype::~my_ctype(){}
bool my_ctype::do_is(mask__m,char_type__c)const{return false;}
const my_ctype::char_type*my_ctype::do_is(const char_type*.\u lo,const char_type*.\u hi,mask*.\u vec)const{return\u hi;}
const my_ctype::char_type*my_ctype::do_scan_is(掩码uu m,const char_type*u lo,const char_type*u hi)const{return u hi;}
const my_ctype::char_type*my_ctype::do_scan_not(掩码uu m,const char_type*u lo,const char_type*u hi)const{return u hi;}
my_ctype::char_ctype::do_toupper(char_ctype_uuuc)const{return\uuuu c;}
const my_ctype::char_type*my_ctype::do_toupper(char_type*.\u lo,const char_type*.\u hi)const{return}
my_ctype::char_ctype::do_tolower(char_ctype uuu c)常量{return uuu c;}
const my_ctype::char_type*my_ctype::do_tolower(char_type*.\u lo,const char_type*.\u hi)const{return}
my_ctype::char_type my_ctype::do_加宽(char__c)常量{return__c;}
const char*my_ctype::do_加宽(const char*\uu lo,const char*\uu hi,char_type*\uu dest)const{return\uu hi;}
char my_ctype::do_狭窄(char_type uu c,char u dfault)常量{return u dfault;}
const my_ctype::char_type*my_ctype::do_狭窄(const char_type*.\u lo,const char_type*.\u hi,char u dfault,char*.\u to)const{return hi;}
int main(){
my_ctype*c=新建my_ctype();
返回0;
}
下面是我得到的错误:

Linking console executable: bin\Debug\ctype.exe
obj\Debug\main.o: In function `_ZN8my_ctypeD2Ev':
D:/[...]/ctype/main.cpp:29: undefined reference to `std::ctype<unsigned int>::~ctype()'
obj\Debug\main.o:main.cpp:(.rdata$_ZTVSt5ctypeIjE[vtable for std::ctype<unsigned int>]+0x8): undefined reference to `std::ctype<unsigned int>::~ctype()'
obj\Debug\main.o:main.cpp:(.rdata$_ZTVSt5ctypeIjE[vtable for std::ctype<unsigned int>]+0xc): undefined reference to `std::ctype<unsigned int>::~ctype()'
obj\Debug\main.o:main.cpp:(.rdata$_ZTVSt5ctypeIjE[vtable for std::ctype<unsigned int>]+0x10): undefined reference to `std::ctype<unsigned int>::do_is(unsigned short, unsigned int) const'
obj\Debug\main.o:main.cpp:(.rdata$_ZTVSt5ctypeIjE[vtable for std::ctype<unsigned int>]+0x14): undefined reference to `std::ctype<unsigned int>::do_is(unsigned int const*, unsigned int const*, unsigned short*) const'
obj\Debug\main.o:main.cpp:(.rdata$_ZTVSt5ctypeIjE[vtable for std::ctype<unsigned int>]+0x18): undefined reference to `std::ctype<unsigned int>::do_scan_is(unsigned short, unsigned int const*, unsigned int const*) const'
obj\Debug\main.o:main.cpp:(.rdata$_ZTVSt5ctypeIjE[vtable for std::ctype<unsigned int>]+0x1c): undefined reference to `std::ctype<unsigned int>::do_scan_not(unsigned short, unsigned int const*, unsigned int const*) const'
obj\Debug\main.o:main.cpp:(.rdata$_ZTVSt5ctypeIjE[vtable for std::ctype<unsigned int>]+0x20): undefined reference to `std::ctype<unsigned int>::do_toupper(unsigned int) const'
obj\Debug\main.o:main.cpp:(.rdata$_ZTVSt5ctypeIjE[vtable for std::ctype<unsigned int>]+0x24): undefined reference to `std::ctype<unsigned int>::do_toupper(unsigned int*, unsigned int const*) const'
obj\Debug\main.o:main.cpp:(.rdata$_ZTVSt5ctypeIjE[vtable for std::ctype<unsigned int>]+0x28): undefined reference to `std::ctype<unsigned int>::do_tolower(unsigned int) const'
obj\Debug\main.o:main.cpp:(.rdata$_ZTVSt5ctypeIjE[vtable for std::ctype<unsigned int>]+0x2c): undefined reference to `std::ctype<unsigned int>::do_tolower(unsigned int*, unsigned int const*) const'
obj\Debug\main.o:main.cpp:(.rdata$_ZTVSt5ctypeIjE[vtable for std::ctype<unsigned int>]+0x30): undefined reference to `std::ctype<unsigned int>::do_widen(char) const'
obj\Debug\main.o:main.cpp:(.rdata$_ZTVSt5ctypeIjE[vtable for std::ctype<unsigned int>]+0x34): undefined reference to `std::ctype<unsigned int>::do_widen(char const*, char const*, unsigned int*) const'
obj\Debug\main.o:main.cpp:(.rdata$_ZTVSt5ctypeIjE[vtable for std::ctype<unsigned int>]+0x38): undefined reference to `std::ctype<unsigned int>::do_narrow(unsigned int, char) const'
obj\Debug\main.o:main.cpp:(.rdata$_ZTVSt5ctypeIjE[vtable for std::ctype<unsigned int>]+0x3c): undefined reference to `std::ctype<unsigned int>::do_narrow(unsigned int const*, unsigned int const*, char, char*) const'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
15 errors, 1 warnings
链接控制台可执行文件:bin\Debug\ctype.exe
obj\Debug\main.o:在函数“\u ZN8my\u ctypeD2Ev”中:
D://[…]/ctype/main.cpp:29:对“std::ctype::~ctype()”的未定义引用
obj\Debug\main.o:main.cpp:(.rdata$\u ZTVSt5ctypeIjE[vtable for std::ctype]+0x8):未定义对“std::ctype::~ctype()的引用”
obj\Debug\main.o:main.cpp:(.rdata$\u ZTVSt5ctypeIjE[vtable for std::ctype]+0xc):未定义对“std::ctype::~ctype()的引用”
obj\Debug\main.o:main.cpp:(.rdata$\u ZTVSt5ctypeIjE[vtable for std::ctype]+0x10):对'std::ctype::do_is(无符号短,无符号int)const'的未定义引用
obj\Debug\main.o:main.cpp:(.rdata$_ZTVSt5ctypeIjE[vtable for std::ctype]+0x14):未定义对“std::ctype::do_is(unsigned int const*、unsigned int const*、unsigned short*)const”的引用
obj\Debug\main.o:main.cpp:(.rdata$\u ZTVSt5ctypeIjE[vtable for std::ctype]+0x18):对“std::ctype::do_scan”的未定义引用是(无符号短,无符号int const*,无符号int const*)const'
obj\Debug\main.o:main.cpp:(.rdata$\ZTVSt5ctypeIjE[vtable for std::ctype]+0x1c):未定义对“std::ctype::do_scan_not(无符号短、无符号int const*、无符号int const*)const”的引用
obj\Debug\main.o:main.cpp:(.rdata$\ZTVSt5ctypeIjE[vtable for std::ctype]+0x20):对“std::ctype::do_toupper(unsigned int)const”的未定义引用
obj\Debug\main.o:main.cpp:(.rdata$\u ZTVSt5ctypeIjE[vtable for std::ctype]+0x24):未定义对“std::ctype::do_toupper(unsigned int*,unsigned int const*)const”的引用
obj\Debug\main.o:main.cpp:(.rdata$\ZTVSt5ctypeIjE[vtable for std::ctype]+0x28):对“std::ctype::do_tolower(unsigned int)const”的未定义引用
obj\Debug\main.o:main.cpp:(.rdata$\ZTVSt5ctypeIjE[vtable for std::ctype]+0x2c):未定义对“std::ctype::do_tolower(unsigned int*,unsigned int const*)const”的引用
obj\Debug\main.o:main.cpp:(.rdata$\ZTVSt5ctypeIjE[vtable for std::ctype]+0x30):对“std::ctype::do_加宽(char)const”的未定义引用
obj\Debug\main.o:main.cpp:(.rdata$\u ZTVSt5ctypeIjE[vtable for std::ctype]+0x34):未定义对“std::ctype::do_加宽(char const*,char const*,unsigned int*)const”的引用
obj\Debug\main.o:main.cpp:(.rdata$\ZTVSt5ctypeIjE[vtable for std::ctype]+0x38):未定义对“std::ctype::do_shown(unsigned int,char)const”的引用
obj\Debug\main.o:main.cpp:(.rdata$ZTVSt5ctypeIjE[vtable for std::ctype]+0x3c):未定义对“std::ctype::do_shown(unsigned int const*,unsigned int const*,char,char*)const”的引用
collect2.exe:错误:ld返回了1个退出状态
进程以状态1终止(0分1秒)
15个错误,1个警告
我查看了locale_facets.h,发现ctype和ctype有模板专门化,我担心我可能也必须为uint32_t创建专门化,但我不明白为什么

下面是我的问题:

1-为什么我会收到这些错误消息

2-如何修复它

3-如果我必须为uint32\u t专门化ctype,为什么会这样

我在windows上用mingw通过代码块编译我的程序。测试程序只有main.cpp,没有其他文件

  • 因为uint32\t没有专门化
  • 写一篇特别的文章