Condition Expression of type StudentType is Illegal

Would anybody know why I get this error saying that conditional expression of type 'studentType' is illegal?

This part is coming from my orderedLinkList header
Here is the code piece where it says its illegal.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
bool orderedLinkedList<Type>::search(const Type& searchItem) const
{
    bool found = false;
    nodeType<Type> *current; //pointer to traverse the list

    current = first;  //start the search at the first node

    while (current != NULL && !found)
        if (current->info >= searchItem) //THIS IS WHERE ITS ILLEGAL
            found = true;
        else
            current = current->link;
 
    if (found)
       found = (current->info == searchItem); //test for equality

    return found;
}//end search



Here are the prototypes in StudentType Header
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <string>



class studentType{


private:
	int ID;
	std::string Fname;
	std::string Lname;
	float GPA;
	
public:
	studentType();
	studentType(int ID,std::string Fname,std::string Lname,float GPA);
	void setStudent(int ID, std::string Fname,std::string Lname, float GPA);
	int getID();
	std::string getFirstName();
	std::string getLastName();
	float getGPA();
	void print();
	friend std::ostream& operator<<(std::ostream& out, studentType const& obj);
	friend std::istream& operator>>(std::istream& in, studentType& obj);
	studentType operator>=(const studentType& obj);

};



Please copy and paste the exact error message and indicate which line it is referring to.
Error 1 error C2451: conditional expression of type 'studentType' is illegal on line 9 on top code

It seems that you have not provided an implementation for operator>= for your studentType class. Look up operator overloading.
Oh Ok. I see. Thanks.
Your studentType operator>=(const studentType& obj); returns studentType but it actually needs to return bool:

bool operator>=(const studentType& obj) const;

better make it const so that it works on const objects of this type
Topic archived. No new replies allowed.