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++

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

A verb for when some rights are not violated?

Does a humanoid possessed by a ghost register as undead to a paladin's Divine Sense?

Is an "are" omitted in this sentence

How can I use commands with sudo without changing owner of the files?

Plotting Autoregressive Functions / Linear Difference Equations

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

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

foot-pounds of energy?

Are the related objects in an SOQL query shared?

Is it possible to Clear (recover memory from) a specific index to a variable, while leaving other indices to the same variable untouched?

Repeated! Factorials!

Is there a booking app or site that lets you specify your gender for shared dormitories?

Need reasons why a satellite network would not work

Broken bottom bracket?

Why do rocket engines use nitrogen actuators to operate the fuel/oxidiser valves instead of electric servos?

Write The Shortest Program To Check If A Binary Tree Is Balanced

how to change dot to underline in multiple file-names?

How to check a file was encrypted (really & correctly)

The Game of the Century - why didn't Byrne take the rook after he forked Fischer?

split inside flalign

How do people drown while wearing a life jacket?

Is there a command-line tool for converting html files to pdf?

How does Rust's 128-bit integer `i128` work on a 64-bit system?



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
    9 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
    9 hours ago











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

    – ruohola
    8 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
    9 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
    9 hours ago











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

    – ruohola
    8 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 9 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
    9 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
    9 hours ago











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

    – ruohola
    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
    9 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
    9 hours ago











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

    – ruohola
    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
9 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
9 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
9 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
9 hours ago













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

– ruohola
8 hours ago





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

– ruohola
8 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
      9 hours ago






    • 3





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

      – Doch88
      9 hours ago







    • 2





      @VladfromMoscow why?

      – Henri
      9 hours ago






    • 3





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

      – Jesper Juhl
      9 hours ago







    • 1





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

      – Vlad from Moscow
      9 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 9 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
              9 hours ago






            • 3





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

              – Doch88
              9 hours ago







            • 2





              @VladfromMoscow why?

              – Henri
              9 hours ago






            • 3





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

              – Jesper Juhl
              9 hours ago







            • 1





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

              – Vlad from Moscow
              9 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
              9 hours ago






            • 3





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

              – Doch88
              9 hours ago







            • 2





              @VladfromMoscow why?

              – Henri
              9 hours ago






            • 3





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

              – Jesper Juhl
              9 hours ago







            • 1





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

              – Vlad from Moscow
              9 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 9 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
              9 hours ago






            • 3





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

              – Doch88
              9 hours ago







            • 2





              @VladfromMoscow why?

              – Henri
              9 hours ago






            • 3





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

              – Jesper Juhl
              9 hours ago







            • 1





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

              – Vlad from Moscow
              9 hours ago













            • 1





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

              – Rakete1111
              9 hours ago






            • 3





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

              – Doch88
              9 hours ago







            • 2





              @VladfromMoscow why?

              – Henri
              9 hours ago






            • 3





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

              – Jesper Juhl
              9 hours ago







            • 1





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

              – Vlad from Moscow
              9 hours ago








            1




            1





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

            – Rakete1111
            9 hours ago





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

            – Rakete1111
            9 hours ago




            3




            3





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

            – Doch88
            9 hours ago






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

            – Doch88
            9 hours ago





            2




            2





            @VladfromMoscow why?

            – Henri
            9 hours ago





            @VladfromMoscow why?

            – Henri
            9 hours ago




            3




            3





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

            – Jesper Juhl
            9 hours ago






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

            – Jesper Juhl
            9 hours ago





            1




            1





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

            – Vlad from Moscow
            9 hours ago






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

            – Vlad from Moscow
            9 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

            ParseJSON using SSJSUsing AMPscript with SSJS ActivitiesHow to resubscribe a user in Marketing cloud using SSJS?Pulling Subscriber Status from Lists using SSJSRetrieving Emails using SSJSProblem in updating DE using SSJSUsing SSJS to send single email in Marketing CloudError adding EmailSendDefinition using SSJS

            Кампала Садржај Географија Географија Историја Становништво Привреда Партнерски градови Референце Спољашње везе Мени за навигацију0°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.340°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.34МедијиПодациЗванични веб-сајту

            19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу