Forum: C++ Mar 6th, 2009 |
| Replies: 6 Views: 4,134 I don't know if there is any stl hash_map. U need to use just map instead, with a #include <map> |
Forum: C++ Mar 5th, 2009 |
| Replies: 6 Views: 4,134 The map as a whole can not displayed using cout. Try |
Forum: C++ Mar 5th, 2009 |
| Replies: 6 Views: 696 Of course, if you put the delete statement after the return statement, it won't be executed at all. Instead you can do like |
Forum: C++ Mar 5th, 2009 |
| Replies: 6 Views: 696 If you are afraid of delete, using auto_ptr can be a good option. |
Forum: C++ Feb 19th, 2009 |
| Replies: 7 Views: 1,160 The problem is that when your function is returning a string, it first makes a copy of the string to be returned (in your case, it is NULL). For making copy, it has to take the length of the original... |
Forum: C++ Feb 18th, 2009 |
| Replies: 4 Views: 301 The problem seems to be in
while(isalpha(ch))
{
text[i] = ch;
i++;
}
If the first character is an alphabet, it will go on filling the array text with that... |
Forum: C++ Feb 9th, 2009 |
| Replies: 4 Views: 636 only the first example invokes copy constructor. If the second one needs to work in the same manner as copy constructor does, you have to overload the assignment operator. |
Forum: C++ Jan 15th, 2009 |
| Replies: 8 Views: 539 [] operator is the best to add values to an array, I think. Applicable only if you know the index in advance.
If you have to search in runtime for the position to which we can add a value, it will... |
Forum: C++ Jan 15th, 2009 |
| Replies: 13 Views: 1,076 I wonder when the loop while (*a++ = *temp++) will end. Also, as you have done an a++, the beginning of the string is altered.
I suggest using the following code.
int i = 0;
while (i <... |