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>#include<sstream>usingnamespacestd;/*Enter code for class Student here.Read statement for specification.*/classStudent{private:intage;intstandard;stringfirst_name;stringlast_name;public:// settervoidset_age(intageV){age=ageV;}voidset_standard(unsignedstandardV){standard=standardV;}voidset_first_name(stringfirstName){first_name=firstName;}voidset_last_name(stringlastName){last_name=lastName;}// getterintget_age(){returnage;}intget_standard(){returnstandard;}stringget_first_name(){returnfirst_name;}stringget_last_name(){returnlast_name;}stringto_string(){stringresult=std::to_string(age)+','+get_first_name()+','+get_last_name()+','+std::to_string(standard);returnresult;}};intmain(){intage,standard;stringfirst_name,last_name;cin>>age>>first_name>>last_name>>standard;Studentst;st.set_age(age);st.set_standard(standard);st.set_first_name(first_name);st.set_last_name(last_name);cout<<st.get_age()<<"\n";cout<<st.get_last_name()<<", "<<st.get_first_name()<<"\n";cout<<st.get_standard()<<"\n";cout<<"\n";cout<<st.to_string();return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Class
You are viewing a single comment's thread. Return to all comments →