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 8763561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:48:26+00:00 2026-06-13T15:48:26+00:00

I read this about class in the C++ standard document: A class is a

  • 0

I read this about class in the C++ standard document:

A class is a type. Its name becomes a class-name (9.1) within its
scope.

class-name: identifier template-id

I found this grammar for an identifier in the C++ Standard:

 2.10 Identifiers
 identifier: nondigit
 identifier nondigit
 identifier digit

 nondigit: one of universal-character-name 
 _ a b c d e f g h i j k l m n o p q r s t u  v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 
 digit: one of 0 1 2 3 4 5 6 7 8 9

Now I tried doing this:

class
{
public:
  int i;
};

and it compiles fine without any name.

Can anyone give me an explanation regarding this? Isn’t it a violation of the grammar specified for an identifier?


Nawaz had asked a follow up question regarding the standard compliance of the code I had given. Those interested can check it out here.

  • 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-06-13T15:48:27+00:00Added an answer on June 13, 2026 at 3:48 pm

    The grammar goes

    class-specifier:
        class-head { member-specification_opt }
    
    class-head:
        class-key attribute-specifier-seq_opt class-head-name class-virt-specifier-seq_opt base-clause_opt
        class-key attribute-specifier-seq_opt base-clause_opt
    
    class-key:
        class
        struct
        union
    

    In your case, the second production of class-head is used — no class-name is involved.

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

Sidebar

Related Questions

I read about this class : Do not instantiate this class directly, instead, call
What I read in the C++ standard about injected class names contradicts (as I
I've read this answer about eight-five times, but there's something I'm not understanding correctly:
I have read this article about 400% boost of your website . This is
I read this good article about Routed Events, and I understood why we need
I've read this book section about git branches. I have create a branch called
I am sure I read about this the other day but I can't seem
I just read this great answer from BalusC about how to upload files with
You can read this question where I ask about the best architecture for a
I have read this article from High Scalability about Stack Overflow and other large

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.