We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<iostream>usingnamespacestd;classPerson{public:Person(conststring&first_name,conststring&last_name):first_name_(first_name),last_name_(last_name){}conststring&get_first_name()const{returnfirst_name_;}conststring&get_last_name()const{returnlast_name_;}private:stringfirst_name_;stringlast_name_;};// Enter your code here.ostream&operator<<(ostream&os,constPerson&p){os<<"first_name="+p.get_first_name()+",last_name="+p.get_last_name();returnos;}intmain(){stringfirst_name,last_name,event;cin>>first_name>>last_name>>event;autop=Person(first_name,last_name);cout<<p<<" "<<event<<endl;return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Overloading Ostream Operator
You are viewing a single comment's thread. Return to all comments →