but that would mean that i would have to put all the charc in an array. then count whats in the array. and take the sum of all the ascii values (for the sum).
also i get an error for endl, VS says that there is no operator that handles endl.
You dont have to do anything involving copying stuff into an array. A char* is already an array
If you have the function
Code:
Void foo(char* arg)
{
}
foo("abcde");
and you want to count the number of characters just use strlen(). And if you want to compute the sum, use a for loop and index 'arg' the same was as you would with an array
arrays and pointers are basically the same thing.
The only thing you need to keep track of between calls to the operator is:
1) Total number of characters
2) Sum of integral values of characters.
So there's no reason to do anything crazy like keeping one big long string in the class that you keep concatenating over and over. Just each time the operator is called, a) take the length and add it to your running sum, and b) compute the arithmetic sum of the input and add it to a separate running sum.
I mean no disrespect, but if you intend to pursue computer science as your major or some such, I would really advise some outside help or perhaps retaking an earlier class. Don't get me wrong, I don't mind helping you until the cows come home, but the problem IMO is that you missed some of the much more fundamental aspects of C / C++ programming that you should have learned in an earlier course.
Of course, there's a chance you only want to pass the course because it's required for some kind of engineering degree or something, in which case maybe you just want to skate through.