回答
在tutorialspoint我尝试:
#include <iostream>
#include <typeinfo>
using namespace std;
int main()
{
cout << typeid("abc").name() << endl;
cout << typeid (const char *).name() << endl;
cout << typeid(char *).name() << endl;
cout << typeid(char[4]).name() << endl;
cout << typeid(const char[4]).name() << endl;
return 0;
}
输出是:
A4_c
PKC
PC
A4_c
A4_c
似乎炭[4]或为const char [4 ]但肯定不是char *或者const char *
它是'const char [4]',按照C++ 11§2.14.5¶8(*普通字符串文字和UTF-8字符串文字也被称为窄字符串文字。窄字符串文字具有类型“array 'n'const char'“,其中n是下面定义的字符串的大小,并具有静态存储持续时间(3.7)。*) – 2015-01-21 12:44:46
不要使用'typeid'来告诉类型。有时由标准保证给你错误的答案。 – 2015-01-21 13:05:23
我会猜想它也是const char [4]。我用typeid来说明。对于一个更纯粹的答案,你会写出可能为char [N]中的数字模板化的重载,并查看哪一个可以打印。 – CashCow 2015-01-21 14:14:12
- 1. 什么是C#中的匿名类型?
- 2. 什么是C中的复合类型?
- 3. C#中“half”(binary16)的类型是什么?
- 4. 什么是C++中的char()类型?
- 5. 什么是C#中的可空类型?
- 6. jQuery中$('abc')和$(“abc”)有什么区别?
- 7. 什么是“int?”在C#类型中
- 8. 什么是Objective-C的枚举类型
- 9. C:&array_name的类型是什么?
- 10. WINOLEAPI的C#数据类型是什么?
- 11. * abc的正则表达式是什么?
- 12. 什么是kdb + capital C类型?
- 13. 什么是C “类型名称” ++
- 14. C#。什么类型必须是可变
- 15. 为什么输入“abc !!!”但输出不是“abC+++”?
- 16. 什么是类型和什么是类型构造函数scala
- 17. LetterP的类型是什么?
- 18. 什么是MouseEventArgs.X的类型?
- 19. T的类型是什么?
- 20. 什么是setContentView()的类型
- 21. 这是什么onclick(onclick =“this.name ='abc'”)是什么意思?
- 22. C#需要什么类型?
- 23. WCF中的ABC代表什么?
- 24. 为什么C#中匿名类型的属性是只读的?
- 25. C++中的字符串文字的类型是什么?
- 26. 在C#中,什么是`?`的`类型的DateTime?`
- 27. 什么是语法的变量类型:Objective-C中的'somestring'?
- 28. 此模板中的类型是什么?
- 29. 什么是cmake中的MODULE库类型?
- 30. Qt中的SLOT类型是什么?
它实际上是'const char [4]'。 – 2015-01-21 12:17:10
我遇到了一个奇怪的铛++编译器行为使用C++ 11 std :: regex_replace。编译器不会接受: 'std :: string text =“快速棕色狐狸”;' 'std :: regex vowel_re(“a | e | i | o | u”);' 错误 - > std :: cout <<'\ n'<< std :: regex_replace(text,vowel_re,“[$&]”)<<'\ n';' works - >'std :: cout < <'\ n'<< std :: regex_replace(text,vowel_re,std :: string(“[$&]”))<<'\ n';' – tisch 2015-01-21 12:21:01
@tisch这是一个完全不相关的问题相信你必须传递'std :: string {“[$&]”}') – Barry 2015-01-21 12:25:25