First, when do you know that an operator is overloaded? I see some exercises where they ask to overload the += operator. How do you overload, and not-overload it ?! whats the main point ?!
Second, I have an exercise where I should write an operator +=, that adds another object of a class (which is under another class). I usualy do that with a FOR cyclus, but this time time I have no COUNTER.
Here is the code, I hope it explains better:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
class student
{
private:
char imepre[50];
char nasoka[4];
ispit *is;
public:
student(char *i="",char *n="")
{
strcpy(imepre,i);
strcpy(nasoka,n);
}
|
(
ispit *is) , is a dynamic allocated object from another class.
No, I have to write a
+= operator, which allows a new "
IS" object to be added to the curent
LIST of
IS
-es, a list which is empty at the beggining.
I would know to solve this, if there was a previously declared counter, but I can't this way :/