Are array of pointers to different types possible in c++?

后端 未结 7 611
灰色年华
灰色年华 2020-12-18 03:46

Are array of pointers to different types possible in c++? with example please)

7条回答
  •  失恋的感觉
    2020-12-18 03:57

    #include 
    
    int main(void)
    {
      void * ptr[2];
      int *a;
      int b;
    
      ptr[0] = "[0] = \"This is a string & c does it better\", [1] = ";
      *a = 2;
      ptr[1] = a;
      b = *((int *) ptr[1]);
      printf("%s",  (char *) ptr[0] );
      printf("%i\n", b );
    
      return 0;
    }
    

提交回复
热议问题