0

In the C++ book I am reading. It gives the syntax for initialisation as

int *pInteger = NULL;

However it also showed the following as an example

int Age = 30;

int* pInteger = &Age;

Why is there a discrepancy? i.e. * after the int and * before the pInteger. Is the following correct?

int Age = 30;

int *pInteger = &Age;
Lost1
  • 990
  • 1
  • 14
  • 34

1 Answers1

1

C++ is generally a free-form language. You can use whitespace pretty much however you like. All of the following are equivalent:

int *foo1;
int* foo2;
int * foo3;
int*foo4;
melpomene
  • 84,125
  • 8
  • 85
  • 148