fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. class Data
  7. {
  8. public:
  9. Data(unsigned d, unsigned m, unsigned y): d(d), m(m), y(y)
  10. {
  11. sprintf(buf, "%u-%u-%u", d, m, y);
  12. }
  13.  
  14. char* display()
  15. {
  16. return buf;
  17. }
  18.  
  19. private:
  20. unsigned d, m, y;
  21. char buf[20];
  22. };
  23.  
  24. int main()
  25. {
  26. Data d(10, 20, 1990);
  27. cout << d.display() << endl;
  28. return 0;
  29. }
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
10-20-1990