Hi there!

I keep getting an error stating error: expected unqualified-id before 'bool' when I try to compile this file

#include "Data.h"
#include <iostream>

Data::Data()
{
}

Data::Data(char aLetter, int anOrder)
{
	letter=aLetter;
	order=anOrder;
}

Data::~Data()
{
}



ostream& operator<< (ostream& out,const Data& someData)  
{  
	out << "(" << someData.order << ", " <<  
	someData.letter << ")";  
	return out;  
} 

Data::bool operator<(Data& someData)
{
	return this->order<someData.order;
}
#ifndef Data_H_include
#define	DATA_H_include
#include <iostream>

using namespace std;

class Data
{
	private:
		int order;
		char letter;

	public:
		
		Data();

		Data(char, int);
		
		~Data();  
		
	bool operator<(const Data&) const;

	friend ostream& operator<<(ostream&,const Data&);
};
#endif

I'm getting fairly frustrated as I am not sure what to put before bool. Can anyone help me?

Recommended Answers

All 3 Replies

Been a while since I've used that syntax, but I think it is supposed to be:

bool Data::operator

Compare bool operator<(const Data&) const; in the class definition and operator<(Data& someData) in the member function implementation.
And correct this awful Data::bool operator<(Data& someData) to

bool Data::operator<(const Data& ...

actually the first one is correct. LOL, I found out on the 1001th try

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.