The address of character type variable

后端 未结 3 715

Here is just a test prototype :

#include 
#include 
using namespace std;

int main()
{
   int a=10;
   char b=\'H\';
   string          


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-20 11:36

    The << operator in your code is overloaded in C++ 11. It doesn't conflict with any of other types like int or string, but it takes pointer to char which if used can produce undesired results.

    You can do it like:-

    cout << static_cast(&b)
    

提交回复
热议问题