Thanks a lot Andy! Now I understand everything :)
There is another problem I have related with this class, but since it is totally different, I wrote another topic for it. Hope it's fine.
EDIT: since I am having errors posting another topic, here is the second problem I have:
Hello :)
I have the following problem. There is a class Vector I wrote myself for learning purposes. In this class, I have overloaded the << operator. The code for this is:
1 2 3 4 5 6 7 8 9 10
|
std::ostream& operator<<(std::ostream& output,const Vector& v)
{
output << "(";
for(int i=0 ; i<v.GetSize() ; i++)
{
output << v(i) << ", ";
}
std::cout << ")";
return output;
}
|
This works perfectly fine. If I have a Vector named "jci" that consists of 3 zeros, then by typing:
std::cout << jci
I will obviously receive:
(0, 0, 0)
which is fine. But what if I would like to receive:
jci = (0,0,0)
How do I tell my overloaded function how did the programmer name the instance of the class? That in my main file I typed "Vector jci"? Apart from the obvious solution - adding the name of the instance as a member of the class?