![]() |
| | #1 |
| Registered User Join Date: Sep 2009 Location: california
Posts: 7
| Need some more help this time with Pointer help it to the end of a string. Code:
STRING& STRING::operator+=(char* c)
{
char* Temp = new char [Len+1];
for (unsigned I= 0; I <Len; I++){
Temp [i]= STR[i];
}
Len+=1;
Temp[Len]=char(c); // this is where im trying to add the pointer
delete [] STR;
STR = Temp;
return *this;
}
|
| akairyuu is offline | |
| | #2 |
| Ex scientia vera Join Date: Sep 2007
Posts: 426
| If this is the overload that only adds a single character, then you need to change your code: Code: STRING& STRING::operator+=(char* c) // Remove part in red
{
char* Temp = new char [Len+1];
for (unsigned I= 0; I <Len; I++){
Temp [i]= STR[i];
}
Len+=1;
Temp[Len]=char(c); // this is where im trying to add the pointer
delete [] STR;
STR = Temp;
return *this;
}
__________________ "What's up, Doc?" "'Up' is a relative concept. It has no intrinsic value." |
| IceDane is offline | |
![]() |
| Tags |
| pointers |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| need help in time zone | Gong | C++ Programming | 2 | 01-03-2007 04:44 AM |
| pointers | InvariantLoop | C Programming | 13 | 02-04-2005 09:32 AM |
| towers of hanoi problem | aik_21 | C Programming | 1 | 10-02-2004 01:34 PM |
| Killing someones grandparents | nickname_changed | A Brief History of Cprogramming.com | 37 | 09-07-2003 07:56 AM |
| Contest Results - May 27, 2002 | ygfperson | A Brief History of Cprogramming.com | 18 | 06-18-2002 01:27 PM |