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.
That's the thing, since nothing is stated in the requirements, then you don't need to worry about it. By using 'return' statements you are saying that you are done with this function. But since you aren't getting valid entry, you actually aren't done. So the entry is then completely skipped.
I'm still tinkering with my code (just the fact that we are forced to use char is mind boggling...), but here is a snippet of my professor class:
//setting up Professor classclassProfessor:publicPerson{public:staticintpro_cur_id;Professor(stringname="default",intage=0,intpubs=0,intcur_id=0):Person(name,age),m_pubs(pubs){}//setting up setters for Professor classvoidgetdata(){cin>>m_name>>m_age>>m_pubs;}//setting up getters for Professor classvoidputdata(){cout<<m_name<<" "<<m_age<<" "<<m_pubs<<" "<<++pro_cur_id<<endl;}private:intm_pubs;};
As you can see, I'm not doing any input validation. It's just not needed.
Let me know if you want to see the entire code.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Virtual Functions
You are viewing a single comment's thread. Return to all comments →
That's the thing, since nothing is stated in the requirements, then you don't need to worry about it. By using 'return' statements you are saying that you are done with this function. But since you aren't getting valid entry, you actually aren't done. So the entry is then completely skipped.
I'm still tinkering with my code (just the fact that we are forced to use char is mind boggling...), but here is a snippet of my professor class:
As you can see, I'm not doing any input validation. It's just not needed.
Let me know if you want to see the entire code.