Advertisement
Guest User

Untitled

a guest
May 23rd, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. template<>
  2. aghMatrix<char*> aghMatrix<char*>::operator+(const aghMatrix<char*>& other){//przeladowanei operatora + dla char*
  3. if ((w != other.w) || (k != other.k)) throw aghException(0, "Invalid dimensions", __FILE__, __LINE__);
  4. else{
  5. aghMatrix<char*> nowa(w, k);
  6. char bufor[64];
  7. for (int i = 0; i < w; i++) for (int j = 0; j < k; j++){
  8. strcpy(bufor, tab[i][j]);//przeniesienie pierwszego lancucha do bufora
  9. strcat(bufor, other.tab[i][j]);//dolaczenie drugiego lancucha
  10. nowa.tab[i][j] = new char[strlen(bufor) + 1];//dynamiczna alokacja pamieci dla sumy lancuchow
  11. strcpy(nowa.tab[i][j], bufor);//przeniesienie sumy do tablicy
  12. bufor[0] = '\0';//zresetowanie bufora
  13. };
  14. return nowa;
  15. };
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement