char 类型是c语言中常见的一个数据类型,string是c++中的一个,它的定义为 Strings are objects that represent sequences of characters. 由此可见string是一个char序列的对象,有时候我们经常需要混用这两个数据类型,所以有些常见的错误还是需要避免的: 比如,string的append函数只能加const char类型的,而push_back函数可以加char类型的,也可以直接用 += 来添加char类型的,如果要同时添加两…
关于这三者的区别stackoverrflow里有一个答案是这样说的: 3.9.1 Fundamental types [basic.fundamental] 1 Objects declared as characters char) shall be large enough to store any member of the implementation's basic character set. If a character from this set is stored in a c…