-
August 2nd, 2016, 10:59 AM
#1
Difference between Basemap* basemap and Basemap *basemap
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
-
August 2nd, 2016, 11:21 AM
#2
Re: Difference between Basemap* basemap and Basemap *basemap
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
Code:
Basemap* basemap1, basemap2;
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. Consider
Code:
Basemap *basemap1, *basemap2;
In this case both basemap1 and basemap2 are pointers to Basemap.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
August 2nd, 2016, 12:36 PM
#3
Re: Difference between Basemap* basemap and Basemap *basemap
You can read Stroustrup's answer to the FAQ: Is ``int* p;'' right or is ``int *p;'' right?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|