fork(1) download
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. class MyString
  7. {
  8. private:
  9. char* s;
  10. public:
  11. MyString() {};
  12. MyString(const char* input) {
  13. auto len = sizeof input;
  14. this->s = new char[len];
  15. // strcpy_s(this->s, len, input);
  16. strcpy(this->s, input);
  17. }
  18. friend ostream & operator << (ostream &out, const MyString &ms) {
  19. out << ms.s;
  20. return out;
  21. }
  22. };
  23.  
  24. int main() {
  25. MyString s1("abc");
  26. cout << s1;
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 4280KB
stdin
Standard input is empty
stdout
abc