friend ostream problem
I have a class something like this
friend ostream & operator<<(ostream &os, A<T> & dy);
x,y and value are some public elements of List<T>
ostream & operator<<(ostream &os, A<T> & dy)
I do some operations on list and when I want to print the list elements , I wrote something like in implementation of operator<<, but i get segmentation error. How can i reach those x,y,and value in operator<< implementation?
I note that the overload should be declared as:
That aside, the problem is probably with some other code, e.g., you forgot to initialise something, or you accessed something out of bounds, or you dereferenced a null pointer, etc.
friend std::ostream & operator<<(std::ostream &os, const A<T> & dy);
yeah i think i make one of those, but for example when i write below in other functions
i get what i want ; but in operator<< implementation this does not work :S
Sorry, but there is just not enough information for me to help you. I suggest that you post the smallest and simplest compilable program that demonstrates the error.
From the looks of it, this should be relevant, but it is unclear why you don't get a linker error.
I do some stuff there to avoid linker errors
how should i use this at there?