Dear all,
Can some body explain the difference between
1. Basemap* basemap
and
2. Basemap *basemap
for 1, it is an object creation, But what defines that?
Thanks in advance
Printable View
Dear all,
Can some body explain the difference between
1. Basemap* basemap
and
2. Basemap *basemap
for 1, it is an object creation, But what defines that?
Thanks in advance
There is no difference. They both create an uninitialized variable basemap as a pointer to type Basemap. Whether you use 1) or 2) is really a matter of choice. I prefer 2). Consider
This creates variable basemap1 as a pointer to Basemap and variable basemap2 as type Basemap. The * doesn't bind with the type but with the variable so in this case only basemap1 is a pointer. ConsiderCode:Basemap* basemap1, basemap2;
In this case both basemap1 and basemap2 are pointers to Basemap.Code:Basemap *basemap1, *basemap2;
You can read Stroustrup's answer to the FAQ: Is ``int* p;'' right or is ``int *p;'' right?