fork download
  1. #include <iostream>
  2. #include <type_traits>
  3. #include <cassert>
  4.  
  5. class Factoral
  6. {
  7. public://begin public section
  8. unsigned int get_number() const { return its_number ; }
  9. void set_number(unsigned int number);//accessor member function
  10. unsigned int get_value() const { return its_value ; }
  11. void set_value ();
  12. private://begin private section
  13. unsigned int its_number;//member variable
  14. unsigned int its_value;//member variable
  15. };
  16.  
  17. int main()
  18. {
  19. std::cout << std::boolalpha
  20. << std::has_trivial_default_constructor<unsigned int>::value << '\n' // true
  21. << std::has_trivial_default_constructor<Factoral>::value << '\n' ; // true
  22.  
  23. Factoral myFactoral{} ; // value initialized
  24.  
  25. assert( myFactoral.get_number() == 0 && myFactoral.get_value() == 0 ) ;
  26.  
  27. std::cout << myFactoral.get_number() << '\n' // 0
  28. << myFactoral.get_value() << '\n' ; // 0
  29. }
  30.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
true
true
0
0