POD-ness of a type

D

Dave

Hello all,

It appears that 3.9/10 and 9/4 taken together define POD. The definition
does not seem to exclude base-class subobjects that are non-POD (though it
does exclude data members that are non-POD). So...

class base // non-POD due to str
{
public:
string str;
};

class derived: public base // POD?????
{
public:
int a;
};

According to my interpretation, derived would be POD. This sure doesn't
seem right though. What am I missing?

Thanks,
Dave
 
V

Victor Bazarov

Dave said:
It appears that 3.9/10 and 9/4 taken together define POD. The definition
does not seem to exclude base-class subobjects that are non-POD (though it
does exclude data members that are non-POD). So...

class base // non-POD due to str
{
public:
string str;
};

class derived: public base // POD?????
No.

{
public:
int a;
};

According to my interpretation, derived would be POD. This sure doesn't
seem right though. What am I missing?

You're missing the word "aggregate" in 9/4. Read the definition of
an aggregate in 8.5.1.

Victor
 
A

Andrey Tarasevich

Dave said:
...
It appears that 3.9/10 and 9/4 taken together define POD. The definition
does not seem to exclude base-class subobjects that are non-POD (though it
does exclude data members that are non-POD). So...

class base // non-POD due to str
{
public:
string str;
};

class derived: public base // POD?????
{
public:
int a;
};

According to my interpretation, derived would be POD. This sure doesn't
seem right though. What am I missing?
...

Read the definition again. Only _aggregate_ classes can be POD-classes.
The term "aggregate" is defined in 8.5.1/1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top