Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<>
- aghMatrix<char*> aghMatrix<char*>::operator+(const aghMatrix<char*>& other){//przeladowanei operatora + dla char*
- if ((w != other.w) || (k != other.k)) throw aghException(0, "Invalid dimensions", __FILE__, __LINE__);
- else{
- aghMatrix<char*> nowa(w, k);
- char bufor[64];
- for (int i = 0; i < w; i++) for (int j = 0; j < k; j++){
- strcpy(bufor, tab[i][j]);//przeniesienie pierwszego lancucha do bufora
- strcat(bufor, other.tab[i][j]);//dolaczenie drugiego lancucha
- nowa.tab[i][j] = new char[strlen(bufor) + 1];//dynamiczna alokacja pamieci dla sumy lancuchow
- strcpy(nowa.tab[i][j], bufor);//przeniesienie sumy do tablicy
- bufor[0] = '\0';//zresetowanie bufora
- };
- return nowa;
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement