Warning pls help

Apart from the ifs why do i get a warning:Control reach the end of non void function???

1
2
3
4
5
6
7
8
9
10
11
12
bool CleaningEmployee::equal(CleaningEmployee& check){
	if (id==check.id){
        if(name==check.name && occupation==check.occupation && wap==check.wap && wac==check.wac && wae==check.wae && work==check.work){
			cout<<"The objects are equal"<<endl;
			return true;
			}
	else{
		cout<<"The objects are not equal"<<endl;
		return false;
		}
	}
}
It means that the complier has reached the end of a function, and hasn't encountered a return statement. Control paths are if statements, and switches. That said, you're missing a return statement after the first branch.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
bool CleaningEmployee::equal(...){
	if (...)
        {
            if(...)
            {
	        cout<<"The objects are equal"<<endl;
		return true;
	    }
	    else
            {
		cout<<"The objects are not equal"<<endl;
		return false;
            }
	}

        // <---- Here
}


Wazzak
Last edited on
Topic archived. No new replies allowed.