Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
6.8.5 Initializers and POD
#1
Rule 8-5-1 (Required) "All variables shall have a defined value before they are used."

My reading of this rule leads me to the conclusion that "POD" classes are effectively not allowed, since any user-defined constructor provided to give initial values to non-static member data results in the class no longer being POD. Example:

[code]// Standard headers
#include
#include // std::is_pod

// User-defined structs...how many are POD?
struct Trivial_Ctor { int i; };
struct With_User_Defined_Ctor { int i; With_User_Defined_Ctor() { } };
struct With_Initialised_Member { int i; With_Initialised_Member() : i(0) { } };

int main()
{
std::cout
<t></t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)