I think you mean that friends are like public members, with the exact same syntax (I mean, friend is totally orthogonal, so I'm not sure what you could say is "different" about the syntax). Which are also something to avoid.
Yeah. friend is a crutch for people who don't know about return-by-reference and operator[] and so on.
Like a certain novice programmer I could mention.
#3384Skywise (unregistered)08/25/2004 03:58 pmI tried it once (I didn't inhale)
And I've never used it professionally...
In my off hours, I've been experimenting with various object architectures to gain some experience in *what works*. I tried friend in a MVC type system where I needed some initimate data binding because, y'know, that's what all the IMPORTANT BOOKS say to do.
And boy, it just... sucked. You're better off just making everything public (or use a struct) because now you have to maintain the "relationship" between these items and it kills reuse because now the objects are even more bound together. Never mind that friendship isn't inheritable (I don't "have-a" friend class, I'm "is-a" friend class, but you aint no friend of mine...)
But doesn't this all degenerate down to the "an accessor method is just as bad as a public variable" religious argument?
An accessor method can be validated and bounds-checked, and in the case of return-by-reference it can also be set const (making it read-only) or whatever.
It's onle of those ty[ical c++ features that only make sense when you are doing something highly dubious with other such c++ features. In practice, it's somewhat useful for writing unit tests.
Really? I've always been writing my unit tests by writing a program which uses the module and simulates a wide range of possible valid inputs to it, and comparing it with the expected output, trying to keep everything high-level and abstract. Silly me.
I think you mean that friends are like public members, with the exact same syntax (I mean, friend is totally orthogonal, so I'm not sure what you could say is "different" about the syntax). Which are also something to avoid.
No, that's not what I mean. A friend function is just like a member function. Only the calling syntax is different, f(x) vs x.f(). Otherwise they are fully equivalent. There's no reason whatsoever not to use friends. Of course if you're foolish enough to make a class and its friend function parts of two different functional units, you don't have anyone to blame for your stupidity.
i'm acomputer science student and this is my 3rd year.i was looking for extra information but since it will be from people like you ...i don't want it.........and by the way.. if u don't know the chatting language....it is not my fault
I know "the chatting language" just fine. This isn't IM, and it reeks of disrepect to ask me to make a huge time commitment to helping someone out with their studies without even bothering to be even remotely polite, especially when I have absolutely no obligation to helping out every random stranger who comes by. It disturbs me that you can be a third-year university student and not understand this. What are they teaching kids in school these days about politeness and respect?
You totally miss my point. But, have fun being righteously indignant anyway. Maybe in a few years when you're busy working 80-hour weeks under an intense deadline you'll understand not wanting to take a few hours out of your day to help a third-year student who doesn't even understand a basic linked list or even make the vaguest effort to be pleasant.
"to help a third-year student who doesn't even understand a basic linked list "
we are taking it now but u wouldn't say this if you were the one who has the problem to know the a basic linked list. thats why i'm looking for help....but i didn't think i would meet people telling me things you said .....don't forget that when i first asked i said please but i didn't expect others to tell me that u r not my proffesore or telling me that if i write correctly you will conceder my requist. you could simply say that you are busy or you can not help me. there was no need for all that.....
First off, I didn't say I wasn't your professor, that was zetawoof.
Secondly, I was simply making an observation that you're not really going out of your way to make me want to help you. So far you've continued to make me not want to help you. Not many people would be willing to help you with the way you presented yourself. In fact, I think I'm being very helpful by even taking the time to respond to you with advice on how to ask for help. That's way more useful in life than knowing how to do linked lists.
Comments
friendis totally orthogonal, so I'm not sure what you could say is "different" about the syntax). Which are also something to avoid.friendis a crutch for people who don't know about return-by-reference andoperator[]and so on.Like a certain novice programmer I could mention.
In my off hours, I've been experimenting with various object architectures to gain some experience in *what works*. I tried friend in a MVC type system where I needed some initimate data binding because, y'know, that's what all the IMPORTANT BOOKS say to do.
And boy, it just... sucked. You're better off just making everything public (or use a struct) because now you have to maintain the "relationship" between these items and it kills reuse because now the objects are even more bound together. Never mind that friendship isn't inheritable (I don't "have-a" friend class, I'm "is-a" friend class, but you aint no friend of mine...)
But doesn't this all degenerate down to the "an accessor method is just as bad as a public variable" religious argument?
const(making it read-only) or whatever.No, that's not what I mean. A friend function is just like a member function. Only the calling syntax is different, f(x) vs x.f(). Otherwise they are fully equivalent. There's no reason whatsoever not to use friends. Of course if you're foolish enough to make a class and its friend function parts of two different functional units, you don't have anyone to blame for your stupidity.
how can u help me?
At least, not as far as I know.
you are so encouraging.
but i guess not here.
thanks again for your kindness
Some peoples' children.
we are taking it now but u wouldn't say this if you were the one who has the problem to know the a basic linked list. thats why i'm looking for help....but i didn't think i would meet people telling me things you said .....don't forget that when i first asked i said please but i didn't expect others to tell me that u r not my proffesore or telling me that if i write correctly you will conceder my requist. you could simply say that you are busy or you can not help me. there was no need for all that.....
Secondly, I was simply making an observation that you're not really going out of your way to make me want to help you. So far you've continued to make me not want to help you. Not many people would be willing to help you with the way you presented yourself. In fact, I think I'm being very helpful by even taking the time to respond to you with advice on how to ask for help. That's way more useful in life than knowing how to do linked lists.