C++的"abc"类型是什么?

What is the type of "abc" in C++?

本文关键字:是什么 类型 abc C++      更新时间:2023-10-16

C++中"abc"的类型是什么?候选人可以是const char*char*

还有什么可以想到的吗?

在教程点上,我尝试过:

#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_cPKc
个人电脑

A4_cA4_c

似乎是字符[4]或常量字符

[4],但肯定不是字符*或常量字符*