What does C++ language definition say about the extent of the static keyword?What does the explicit keyword mean?Use 'class' or 'typename' for template parameters?What are the rules about using an underscore in a C++ identifier?When to use static classes in C#The Definitive C++ Book Guide and ListWhat does “static” mean in C?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Why are static variables considered evil?Why are elementwise additions much faster in separate loops than in a combined loop?The static keyword and its various uses in C++

Is a switch from R to Python worth it?

…down the primrose path

What percentage of campground outlets are GFCI or RCD protected?

Broken bottom bracket?

Did Logical Positivism fail because it simply denied human emotion?

ZFS on Linux: Which mountpoint option when mounting manually per script?

How does Geralt transport his swords?

Awk to get all my regular users in shadow

What are the limitations of the Hendersson-Hasselbalch equation?

How to call made-up data?

Can the Cauchy product of divergent series with itself be convergent?

Would the shaking of an earthquake be visible to somebody in a low-flying aircraft?

How to design an effective polearm-bow hybrid?

In MTG, was there ever a five-color deck that worked well?

What is it exactly about flying a Flyboard across the English channel that made Zapata's thighs burn?

Make lens aperture in Tikz

C# TCP server/client class

Is it uncompelling to continue the story with lower stakes?

What could prevent players from leaving an island?

Is there a way to improve my grade after graduation?

Is it okay to use different fingers every time while playing a song on keyboard? Is it considered a bad practice?

How do the surviving Asgardians get to Earth?

What does "autolyco-sentimental" mean?

Are the related objects in an SOQL query shared?



What does C++ language definition say about the extent of the static keyword?


What does the explicit keyword mean?Use 'class' or 'typename' for template parameters?What are the rules about using an underscore in a C++ identifier?When to use static classes in C#The Definitive C++ Book Guide and ListWhat does “static” mean in C?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Why are static variables considered evil?Why are elementwise additions much faster in separate loops than in a combined loop?The static keyword and its various uses in C++






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








7















In C++, if I have a class:



class Example 
static int s_One, s_Two;

...
;


Does the language clearly define that s_Two is also static?



In other words, does the static keyword extent go everywhere the int goes, or can it be like * and only apply to one variable?










share|improve this question
























  • This question can be answered by reading the standard. But, why don't you simply remove the ambiguity by declaring each variable on its own?

    – Jesper Juhl
    8 hours ago







  • 9





    @JesperJuhl: Arguably, most answers about C++ can be answered by reading the standard. But the standard is big and sometimes difficult to navigate.

    – rodrigo
    8 hours ago











  • @JesperJuhl The answer might also be valuable to other people.

    – ruohola
    7 hours ago

















7















In C++, if I have a class:



class Example 
static int s_One, s_Two;

...
;


Does the language clearly define that s_Two is also static?



In other words, does the static keyword extent go everywhere the int goes, or can it be like * and only apply to one variable?










share|improve this question
























  • This question can be answered by reading the standard. But, why don't you simply remove the ambiguity by declaring each variable on its own?

    – Jesper Juhl
    8 hours ago







  • 9





    @JesperJuhl: Arguably, most answers about C++ can be answered by reading the standard. But the standard is big and sometimes difficult to navigate.

    – rodrigo
    8 hours ago











  • @JesperJuhl The answer might also be valuable to other people.

    – ruohola
    7 hours ago













7












7








7








In C++, if I have a class:



class Example 
static int s_One, s_Two;

...
;


Does the language clearly define that s_Two is also static?



In other words, does the static keyword extent go everywhere the int goes, or can it be like * and only apply to one variable?










share|improve this question














In C++, if I have a class:



class Example 
static int s_One, s_Two;

...
;


Does the language clearly define that s_Two is also static?



In other words, does the static keyword extent go everywhere the int goes, or can it be like * and only apply to one variable?







c++ static language-lawyer extent






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 8 hours ago









WilliamKFWilliamKF

16.2k51 gold badges154 silver badges252 bronze badges




16.2k51 gold badges154 silver badges252 bronze badges















  • This question can be answered by reading the standard. But, why don't you simply remove the ambiguity by declaring each variable on its own?

    – Jesper Juhl
    8 hours ago







  • 9





    @JesperJuhl: Arguably, most answers about C++ can be answered by reading the standard. But the standard is big and sometimes difficult to navigate.

    – rodrigo
    8 hours ago











  • @JesperJuhl The answer might also be valuable to other people.

    – ruohola
    7 hours ago

















  • This question can be answered by reading the standard. But, why don't you simply remove the ambiguity by declaring each variable on its own?

    – Jesper Juhl
    8 hours ago







  • 9





    @JesperJuhl: Arguably, most answers about C++ can be answered by reading the standard. But the standard is big and sometimes difficult to navigate.

    – rodrigo
    8 hours ago











  • @JesperJuhl The answer might also be valuable to other people.

    – ruohola
    7 hours ago
















This question can be answered by reading the standard. But, why don't you simply remove the ambiguity by declaring each variable on its own?

– Jesper Juhl
8 hours ago






This question can be answered by reading the standard. But, why don't you simply remove the ambiguity by declaring each variable on its own?

– Jesper Juhl
8 hours ago





9




9





@JesperJuhl: Arguably, most answers about C++ can be answered by reading the standard. But the standard is big and sometimes difficult to navigate.

– rodrigo
8 hours ago





@JesperJuhl: Arguably, most answers about C++ can be answered by reading the standard. But the standard is big and sometimes difficult to navigate.

– rodrigo
8 hours ago













@JesperJuhl The answer might also be valuable to other people.

– ruohola
7 hours ago





@JesperJuhl The answer might also be valuable to other people.

– ruohola
7 hours ago












2 Answers
2






active

oldest

votes


















12














Yes, it applies to every name in that declaration:




[dcl.stc]/1: [..] At most one storage-class-specifier shall appear in a given decl-specifier-seq [..] The storage-class-specifier applies to the name declared by each init-declarator in the list [..]







share|improve this answer
































    0














    According to the C++ 17 Standard (10 Declarations)



    2 A simple-declaration or nodeclspec-function-declaration of the form



    attribute-specifier-seqopt decl-specifier-seqopt init-declarator-listopt ;


    And (10.1 Specifiers):




    1 The specifiers that can be used in a declaration are




    decl-specifier:
    storage-class-specifier
    ...


    So in this declaration



    static int s_One, s_Two;


    the decl-specifier-seq contains two decl-specifiers, static (storage class specifier) and int. Thus the storage class specifier static describes the both variables in the init-declarator-list s_One and s_Two.






    share|improve this answer






















    • 1





      That's not enough; this doesn't show that the SCS applies to both, just that is possible.

      – Rakete1111
      8 hours ago






    • 3





      No, it is not. Why do you say it is invalid?

      – Doch88
      8 hours ago







    • 2





      @VladfromMoscow why?

      – Henri
      8 hours ago






    • 3





      @VladfromMoscow How is declaring two separate static ints invalid syntax?

      – Jesper Juhl
      8 hours ago







    • 1





      @Doch88 I did not see that there is a semicolon instead of comma.:)

      – Vlad from Moscow
      8 hours ago














    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f57362724%2fwhat-does-c-language-definition-say-about-the-extent-of-the-static-keyword%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    12














    Yes, it applies to every name in that declaration:




    [dcl.stc]/1: [..] At most one storage-class-specifier shall appear in a given decl-specifier-seq [..] The storage-class-specifier applies to the name declared by each init-declarator in the list [..]







    share|improve this answer





























      12














      Yes, it applies to every name in that declaration:




      [dcl.stc]/1: [..] At most one storage-class-specifier shall appear in a given decl-specifier-seq [..] The storage-class-specifier applies to the name declared by each init-declarator in the list [..]







      share|improve this answer



























        12












        12








        12







        Yes, it applies to every name in that declaration:




        [dcl.stc]/1: [..] At most one storage-class-specifier shall appear in a given decl-specifier-seq [..] The storage-class-specifier applies to the name declared by each init-declarator in the list [..]







        share|improve this answer













        Yes, it applies to every name in that declaration:




        [dcl.stc]/1: [..] At most one storage-class-specifier shall appear in a given decl-specifier-seq [..] The storage-class-specifier applies to the name declared by each init-declarator in the list [..]








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 8 hours ago









        Lightness Races in OrbitLightness Races in Orbit

        310k58 gold badges512 silver badges857 bronze badges




        310k58 gold badges512 silver badges857 bronze badges


























            0














            According to the C++ 17 Standard (10 Declarations)



            2 A simple-declaration or nodeclspec-function-declaration of the form



            attribute-specifier-seqopt decl-specifier-seqopt init-declarator-listopt ;


            And (10.1 Specifiers):




            1 The specifiers that can be used in a declaration are




            decl-specifier:
            storage-class-specifier
            ...


            So in this declaration



            static int s_One, s_Two;


            the decl-specifier-seq contains two decl-specifiers, static (storage class specifier) and int. Thus the storage class specifier static describes the both variables in the init-declarator-list s_One and s_Two.






            share|improve this answer






















            • 1





              That's not enough; this doesn't show that the SCS applies to both, just that is possible.

              – Rakete1111
              8 hours ago






            • 3





              No, it is not. Why do you say it is invalid?

              – Doch88
              8 hours ago







            • 2





              @VladfromMoscow why?

              – Henri
              8 hours ago






            • 3





              @VladfromMoscow How is declaring two separate static ints invalid syntax?

              – Jesper Juhl
              8 hours ago







            • 1





              @Doch88 I did not see that there is a semicolon instead of comma.:)

              – Vlad from Moscow
              8 hours ago
















            0














            According to the C++ 17 Standard (10 Declarations)



            2 A simple-declaration or nodeclspec-function-declaration of the form



            attribute-specifier-seqopt decl-specifier-seqopt init-declarator-listopt ;


            And (10.1 Specifiers):




            1 The specifiers that can be used in a declaration are




            decl-specifier:
            storage-class-specifier
            ...


            So in this declaration



            static int s_One, s_Two;


            the decl-specifier-seq contains two decl-specifiers, static (storage class specifier) and int. Thus the storage class specifier static describes the both variables in the init-declarator-list s_One and s_Two.






            share|improve this answer






















            • 1





              That's not enough; this doesn't show that the SCS applies to both, just that is possible.

              – Rakete1111
              8 hours ago






            • 3





              No, it is not. Why do you say it is invalid?

              – Doch88
              8 hours ago







            • 2





              @VladfromMoscow why?

              – Henri
              8 hours ago






            • 3





              @VladfromMoscow How is declaring two separate static ints invalid syntax?

              – Jesper Juhl
              8 hours ago







            • 1





              @Doch88 I did not see that there is a semicolon instead of comma.:)

              – Vlad from Moscow
              8 hours ago














            0












            0








            0







            According to the C++ 17 Standard (10 Declarations)



            2 A simple-declaration or nodeclspec-function-declaration of the form



            attribute-specifier-seqopt decl-specifier-seqopt init-declarator-listopt ;


            And (10.1 Specifiers):




            1 The specifiers that can be used in a declaration are




            decl-specifier:
            storage-class-specifier
            ...


            So in this declaration



            static int s_One, s_Two;


            the decl-specifier-seq contains two decl-specifiers, static (storage class specifier) and int. Thus the storage class specifier static describes the both variables in the init-declarator-list s_One and s_Two.






            share|improve this answer















            According to the C++ 17 Standard (10 Declarations)



            2 A simple-declaration or nodeclspec-function-declaration of the form



            attribute-specifier-seqopt decl-specifier-seqopt init-declarator-listopt ;


            And (10.1 Specifiers):




            1 The specifiers that can be used in a declaration are




            decl-specifier:
            storage-class-specifier
            ...


            So in this declaration



            static int s_One, s_Two;


            the decl-specifier-seq contains two decl-specifiers, static (storage class specifier) and int. Thus the storage class specifier static describes the both variables in the init-declarator-list s_One and s_Two.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 8 hours ago

























            answered 8 hours ago









            Vlad from MoscowVlad from Moscow

            148k13 gold badges89 silver badges188 bronze badges




            148k13 gold badges89 silver badges188 bronze badges










            • 1





              That's not enough; this doesn't show that the SCS applies to both, just that is possible.

              – Rakete1111
              8 hours ago






            • 3





              No, it is not. Why do you say it is invalid?

              – Doch88
              8 hours ago







            • 2





              @VladfromMoscow why?

              – Henri
              8 hours ago






            • 3





              @VladfromMoscow How is declaring two separate static ints invalid syntax?

              – Jesper Juhl
              8 hours ago







            • 1





              @Doch88 I did not see that there is a semicolon instead of comma.:)

              – Vlad from Moscow
              8 hours ago













            • 1





              That's not enough; this doesn't show that the SCS applies to both, just that is possible.

              – Rakete1111
              8 hours ago






            • 3





              No, it is not. Why do you say it is invalid?

              – Doch88
              8 hours ago







            • 2





              @VladfromMoscow why?

              – Henri
              8 hours ago






            • 3





              @VladfromMoscow How is declaring two separate static ints invalid syntax?

              – Jesper Juhl
              8 hours ago







            • 1





              @Doch88 I did not see that there is a semicolon instead of comma.:)

              – Vlad from Moscow
              8 hours ago








            1




            1





            That's not enough; this doesn't show that the SCS applies to both, just that is possible.

            – Rakete1111
            8 hours ago





            That's not enough; this doesn't show that the SCS applies to both, just that is possible.

            – Rakete1111
            8 hours ago




            3




            3





            No, it is not. Why do you say it is invalid?

            – Doch88
            8 hours ago






            No, it is not. Why do you say it is invalid?

            – Doch88
            8 hours ago





            2




            2





            @VladfromMoscow why?

            – Henri
            8 hours ago





            @VladfromMoscow why?

            – Henri
            8 hours ago




            3




            3





            @VladfromMoscow How is declaring two separate static ints invalid syntax?

            – Jesper Juhl
            8 hours ago






            @VladfromMoscow How is declaring two separate static ints invalid syntax?

            – Jesper Juhl
            8 hours ago





            1




            1





            @Doch88 I did not see that there is a semicolon instead of comma.:)

            – Vlad from Moscow
            8 hours ago






            @Doch88 I did not see that there is a semicolon instead of comma.:)

            – Vlad from Moscow
            8 hours ago


















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f57362724%2fwhat-does-c-language-definition-say-about-the-extent-of-the-static-keyword%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

            Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

            199年 目錄 大件事 到箇年出世嗰人 到箇年死嗰人 節慶、風俗習慣 導覽選單