CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2016
    Posts
    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

  2. #2
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    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)

  3. #3
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    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?
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

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
  •  





Click Here to Expand Forum to Full Width

Featured