Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<iomanip>
- #include<cstring>
- using namespace std;
- class Sir
- {
- public:
- Sir operator+(char *sir_adaug);
- Sir(char *in_sir)
- {
- strcpy(buffer, in_sir);
- lung=strlen(buffer);
- };
- Sir (void) {lung=0;};
- void arata_sir() { cout<<buffer; };
- private:
- char buffer[256];
- int lung;
- };
- Sir Sir::operator+(char *sir_adaug)
- {
- Sir temp;
- int lungtemp;
- lungtemp=strlen(buffer)+strlen(sir_adaug)+1;
- if(lungtemp>256)
- {
- cout<<"sir prea lung!"<<endl;
- strcpy(temp.buffer, buffer);
- return temp;
- }
- lung=lungtemp;
- strcpy(temp.buffer, buffer);
- strcat(temp.buffer, sir_adaug);
- return temp;
- }
- int main()
- {
- Sir titlu("Jamsa's C/C++ ");
- titlu=titlu+"Programmer's Bible\n";
- titlu.arata_sir();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement