Difference between and ?

前端 未结 10 993
囚心锁ツ
囚心锁ツ 2020-11-27 15:52

How come this code

std::map  m;
m[\"a\"]=1;

compiles with (I\'m using MSVC 2010)

#include 

        
相关标签:
10条回答
  • 2020-11-27 16:12

    string.h is a C header not a C++ header, period!

    0 讨论(0)
  • 2020-11-27 16:14

    <string.h> is a C standard library header while <string> is a cpp in fact all the c standard header files have .h extension an non of cpp have .h.

    0 讨论(0)
  • 2020-11-27 16:14

    string.h is for c compatible c++ string class string is for pure c++ string class

    0 讨论(0)
  • 2020-11-27 16:15

    As stated, string.h and cstring are C headers (while cstring is basically a C++ wrapper for string.h), containing functions for C strings, which are char[] terminated by '\0'. You want to use the c++ class string, which header is <string>.

    0 讨论(0)
  • 2020-11-27 16:18

    string.h is C's header file while string is C++'s header file.

    0 讨论(0)
  • 2020-11-27 16:19

    They are entirely different headers.

    <string> is C++ string class

    <string.h> or <cstring> defines functions to manipulate C strings and arrays

    0 讨论(0)
提交回复
热议问题