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

  • Home
  • SEARCH
  • 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 3237672
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:45:57+00:00 2026-05-17T17:45:57+00:00

Is Demo a POD type in C++03? struct Demo { private: int x; int

  • 0

Is Demo a POD type in C++03?

struct Demo
{
     private:
       int x;
       int y;
};

C++03, §9p4:

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.

After reading Steve Jessop’s post, I believe Demo is a non-POD because the members are private. However the Standard doesn’t say anything about the relation between POD types and access modifiers.

In C++0x Demo is POD because §9p9 (n3126) says:

A POD struct is a class that is both a trivial class and a standard-layout class, and has no non-static data members of type non-POD struct, non-POD union (or array of such types).

Demo is trivial1 as well as a standard-layout class so it is a POD. Is my interpretation correct?

1 A trivial class is a class that has a trivial default constructor (12.1) and is trivially copyable. [9p5, n3126]

  • 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-17T17:45:57+00:00Added an answer on May 17, 2026 at 5:45 pm

    In C++03, it’s definitely not a POD. According to §9/4, “A POD-struct is an aggregate class …”, and according to §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 non-static data members (clause 11), no base classes (clause 10), and no virtual functions (10.3).”

    Under C++0x, at least as of N3090/3092, I believe it is a POD. These require only that all non-static members have the same access, not that the access is necessarily public. This is to fix a problem that I believe I was the first to point out — in C++98/03, a vacuous access specifier leads to a problem:

    struct x { 
        int a;
    public:
        int b;
    public:
       int c;
    };
    

    This fits the requirements of a POD struct — but the standard still gives permission for the relative positions of b and c to be swapped because of the intervening access specifier. As a result, being a POD struct doesn’t provide the layout guarantees that were intended to ensure compatibility with C structs (for the obvious example).

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

Sidebar

Related Questions

class Demo { struct FileData { int size; BYTE* buffer; DWORD flags; }; typedef
public class Demo { public static void main(String args[]) { double d = 12.345;
Consider this demo program: #include <stdio.h> class Base { public: virtual int f(int) =0;
I'm building a demo, and find that I am storing lots of data in
Demo code: import java.lang.ref.PhantomReference; import java.lang.ref.ReferenceQueue; public class Main { public static void main(String[]
I have got a demo script that lets me authorize with my app and
demo for reference: http://greg-j.com/static-content/accordian/ When viewed in any other browser, the toggler works as
This is live demo: http://jsfiddle.net/9Y7Cm/5/ Everything is fine with that, until the text width
I compiled this jsFiddle demo so that you can see what i am going
Original demo http://jsfiddle.net/anglimass/NVTzx/9/ Updated demo (that actually demonstrates the problem) http://jsfiddle.net/NVTzx/16/ Please click see

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.