0

I recently switched from java to c++ and was writing these two lines of code:

    int* a;
    int *b;

I'm wondering what the difference is between these two lines? I've tried searching online but this only talks about the difference between int (*a) and int* a. Or is int *a and int (*a) the same?

Could someone please clarify this for me?

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
codexistent
  • 128
  • 11
  • 5
    There is no difference. Do note that if you want to declare multiple pointers in one line then you need to use `int *bar, *foo, *baz;`, as `int *bar, foo, baz;` declares one pointer and 2 regular `int`s – NathanOliver Apr 21 '23 at 20:43
  • 1
    In C++, in general (ignoring the few oddball edge cases, usually involving macros), whitespace is ignored between tokens. – Eljay Apr 21 '23 at 22:02

0 Answers0