Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DecStr operator+(const DecStr& ob1, const int ob2)
- {
- DecStr tmp(ob1);
- int n1 = atoi(tmp.GetStr()), n2 = ob2;
- long long int A = long long int(n1) + n2;
- if (A < -2147483648 || A > 2147483647) {
- delete[] tmp.pCh;
- tmp.len = 0;
- tmp.pCh = new char[tmp.len + 1];
- tmp.pCh[0] = '\0';
- }
- else {
- char* tmpCh;
- int len2 = 0, tmpn = ob2;
- while (tmpn > 0) {
- len2++;
- tmpn /= 10;
- }
- if (tmp.len < len2) tmp.len = len2;
- tmpCh = new char[tmp.len + 2];
- _itoa_s(A, tmpCh, tmp.len + 2, 10);
- if (tmp.pCh) delete[] tmp.pCh;
- tmp.pCh = tmpCh;
- tmp.len = strlen(tmp.pCh);
- }
- cout << "DecStr operator+(const DecStr& ob1, const int ob2)" << endl;
- return tmp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement