Unable to use friend

Hi!

So for our assignment we can't use 'friend' (friend bool operator > ) but I have to compare two user-inputted values (so I still have to use the bool operator just can't use friend w/ it).

Does anybody have a sample code I can look at for reference to get an idea as to how that is done? Thank you and please let me know if you need more info cause I'm not sure how vague this question is.
Last edited on
>I'm not sure how vague this question is.
Very vaque
>Does anybody have a sample code I can look at for reference to get an idea as to how that is done?
how what is done?Compare variables??
Basically my friend bool function subtracts two variables that are user-inputted. We can't use friend so I can't use two variables so I am stumped. Does that help or no D:> ? Sorry again for the super vague question.
I'm still kind of confused here. What do you mean by "compare two user-inputted values"? It sounds like you don't really need an operator here?

1
2
3
bool compare_less_than(const X& one, const X& two) {
    //whatever
}
There's no relation between 'using two variables' and 'friend'.

With a friend function you can access private/protected members of a class/struct. That's it.

Read this:
http://www.cplusplus.com/doc/tutorial/inheritance/
Topic archived. No new replies allowed.