Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7681757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:24:51+00:00 2026-05-31T18:24:51+00:00

class Test { ; int x; }; Is this perfectly legal and portable?

  • 0
class Test
{
  ;
  int x;
};

Is this perfectly legal and portable?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:24:52+00:00Added an answer on May 31, 2026 at 6:24 pm

    From my reading of the standard, this is not allowed.

    If you look at the grammar definition only, it seems to allow it. The relevant parts are:

    The member-specification is what appears between the { ... } in the class declaration.

    member-specification is a sequence of member-declaration and access specifiers. One possible form for a member-declaration is:

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

    Since everything before the semicolon is optional, it looks like it’s allowed to have an empty
    member-declaration, which consists of only a semicolon.

    However, 9.2/1 says:

    Except when used to declare friends (11.3) or to introduce the name of a member of a base class into a derived class (7.3.3), member-declarations declare members of the class, and each such member-declaration shall declare at least one member name of the class.

    Since an empty member-declaration does not declare at least one member of a class, it seems that this is not standard-compliant, even if some compilers accept it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say i have this usercontrol public class test : UserControl { public int
say I have: class Test { public static int Hello = 5; } This
How would I accomplish this? class Test { private int var1; public Test(int var1)
Say I've got a class like this: class Test { int x; SomeClass s;
Why does this code not work? class Test { int Abc { private set;
class test{ int x; public: //public functions getx() and putx() }; void main() {
interface i1{ int test(); } interface i2{ String test(); } class Test implements i1,i2{
I have an entity and its mapping: public class Test { public virtual int
class Test { public: SOMETHING DoIt(int a) { float FLOAT = 1.2; int INT
If I have a class called Test :: class Test { static std::vector<int> staticVector;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.