Is the POD demo type in C ++ 03?
struct Demo { private: int x; int y; };
C ++ 03, §9p4:
A POD-struct is a cumulative class that does not have non-static data members such as non-POD-struct, non-POD-union (or an array of such types) or a link, and does not have a user-defined purpose for copying an operator without a user-defined destructor.
After reading Steve Jessop's post , I think the demo is a non-POD because the members are private. However, the standard does not say anything about the relationship between POD types and access modifiers.
In C ++ 0x Demo is POD, because §9p9 (n3126) says:
POD - , , non-POD struct, non-POD union ( ).
1 , POD. ?
1 - , (12.1) . [9p5, n3126]
++ 03 POD. § 9/4, "POD- ..." § 8.5.1/1:
- ( 9) , (12.1), ( 11), ( 10) (10.3). "
++ 0x, , N3090/3092, , POD. , , , . , , , - ++ 98/03 :
struct x { int a; public: int b; public: int c; };
POD, - , b c - . POD , C- ( ).
b
c
++ 11 std:: is_pod:
#include <iostream> #include <type_traits> struct Demo { private: int x; int y; }; int main() { std::cout << std::boolalpha; std::cout << std::is_pod<Demo>::value << std::endl; }
True