fork download
  1. #include <iostream>
  2. #include <ctime>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. namespace abc {
  8. class MyClass {
  9. protected:
  10. tm structTime;
  11. public:
  12. MyClass() {
  13. std::time_t t = std::time(nullptr);
  14. structTime = *std::gmtime(&t);
  15. }
  16. const tm& getTM() {
  17. return structTime;
  18. }
  19. std::string foo() {
  20. return asctime (&getTM());
  21. }
  22. };
  23. }
  24.  
  25. int main() {
  26. abc::MyClass myObj;
  27. cout << myObj.foo() << endl;
  28. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
Mon Nov 24 20:47:38 2014