cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Overloading >> operator as non-member fu
Overloading >> operator as non-member function
Feb 24, 2016 at 10:56pm UTC
JonTelep26
(15)
How would I be able to overload my >> operator with the following header:
1
2
3
4
std::istream&
operator
>>(std::istream& ins,Friend& f){
//ins >> f.name >> f.bday;
}
The inside where I have commented out is what I believed I had to do. They are private variables so I am not allowed to set them like that. Without being able to use a set_name or set_bday function, I'm unsure how to approach this.
Feb 24, 2016 at 11:09pm UTC
Yanson
(885)
you need to make it a friend. or add appropriate getters/setters.
Last edited on
Feb 24, 2016 at 11:10pm UTC
Topic archived. No new replies allowed.