[try Beta version]
Not logged in

 
 
Unable to use friend

Apr 12, 2015 at 10:58pm
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 Apr 12, 2015 at 10:59pm
Apr 12, 2015 at 11:44pm
>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??
Apr 16, 2015 at 6:12am
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.
Apr 16, 2015 at 6:51am
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
}
Apr 16, 2015 at 8:09am
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.