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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:53:26+00:00 2026-05-20T21:53:26+00:00

I have a class and a const variable. struct A { int b; };

  • 0

I have a class and a const variable.

struct A 
{
    int b;
};

A const a;

The class A is POD and can be initialized like this.

A const a = { 3 };

IMHO, it looks fine to have a constructor like this.

struct A 
{
    int b;

    A(int newB) : b(newB)
    {
    }
};

But Clang assumes A as non-aggregate type. Why I can’t have constructor like that? Or should I do something else?


I modified question to present my original meaning. I had wrote the struct as class by mistake, and sorry for @Johannes about confusing 🙂

  • 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-20T21:53:27+00:00Added an answer on May 20, 2026 at 9:53 pm

    POD means Plain Old Data type which by definition cannot have user-defined constructor.

    POD is actually an aggregate type (see the next quotation). So what is aggregate? The C++ Standard says in section §8.5.1/1,

    An aggregate is an array or a class
    (clause 9) with no user-declared
    constructors
    (12.1), no private or
    protected nonstatic data members
    (clause 11), no base classes (clause
    10), and no virtual functions (10.3).

    And section §9/4 from the C++ Standard says,

    [….] A POD-struct is an aggregate class that has no non-static data
    members of type non-POD-struct,
    non-POD-union (or array of such types)
    or reference, and has no user-defined
    copy assignment operator
    and no
    user-defined destructor
    . Similarly, a
    POD-union is an aggregate union that
    has no non-static data members of type
    non-POD-struct, non-POD-union (or
    array of such types) or reference, and
    has no user-defined copy assignment
    operator
    and no user-defined
    destructor
    . A POD class is a class
    that is either a POD-struct or a
    POD-union.

    From this, its also clear that POD class/struct/union though cannot have user-defined assignment operator and user-defined destructor also.


    There are however other types of POD. The section §3.9/10 says,

    Arithmetic types (3.9.1),
    enumeration types, pointer types, and
    pointer to member types (3.9.2), and
    cv-qualified versions of these types
    (3.9.3) are collectively called scalar
    types. Scalar types, POD-struct types,
    POD-union types (clause 9), arrays of
    such types and cv-qualified versions
    of these types (3.9.3) are
    collectively called POD types
    .

    Read this FAQ : What is a “POD type”?

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

Sidebar

Related Questions

I have a class with static method which has a local static variable. I
Is there a way to enumerate the members of a structure (struct | class)
Suppose I have the following two data structures: std::vector<int> all_items; std::set<int> bad_items; The all_items
I have a list of types defined as: typedef boost::mpl::list<Apple, Pear, Brick> OriginalList; I
I have the following chunk of a header file BKE_mesh.h: /* Connectivity data */
I'm having trouble deciding whether not this code should compile or if just both
I am trying to attach a function-object to be called on destruction of a
It is common knowledge that built-in enums in C++ are not typesafe. I was
Why does the following code not give me a duplicate symbol linker error for
Just because I've never read binary files before I wrote a program that reads

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.