Virtual Functions

  • + 2 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:

    //setting up Professor class
    class Professor :public Person
    {
    public:
    	static int pro_cur_id;
    	
    	Professor(string name = "default", int age = 0, int pubs = 0, int cur_id = 0) :Person(name, age), m_pubs(pubs) { }
    	
    	//setting up setters for Professor class
    	void getdata()
    	{
    		cin >> m_name >> m_age >> m_pubs;
    	}
    	
    	//setting up getters for Professor class
    	void putdata()
    	{
    		cout << m_name << " " << m_age << " " << m_pubs << " " << ++pro_cur_id << endl;
    	}
    
    private:
    	int m_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.