Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include<iostream>
  2. #include<iomanip>
  3. #include<cstring>
  4. using namespace std;
  5. class Sir
  6. {
  7. public:
  8. Sir operator+(char *sir_adaug);
  9. Sir(char *in_sir)
  10. {
  11. strcpy(buffer, in_sir);
  12. lung=strlen(buffer);
  13. };
  14. Sir (void) {lung=0;};
  15. void arata_sir() { cout<<buffer; };
  16. private:
  17. char buffer[256];
  18. int lung;
  19. };
  20.  
  21. Sir Sir::operator+(char *sir_adaug)
  22. {
  23. Sir temp;
  24. int lungtemp;
  25. lungtemp=strlen(buffer)+strlen(sir_adaug)+1;
  26. if(lungtemp>256)
  27. {
  28. cout<<"sir prea lung!"<<endl;
  29. strcpy(temp.buffer, buffer);
  30. return temp;
  31. }
  32. lung=lungtemp;
  33. strcpy(temp.buffer, buffer);
  34. strcat(temp.buffer, sir_adaug);
  35. return temp;
  36. }
  37.  
  38. int main()
  39. {
  40. Sir titlu("Jamsa's C/C++ ");
  41. titlu=titlu+"Programmer's Bible\n";
  42. titlu.arata_sir();
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement