0

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?

3
Contributors
3
Replies
8
Views
8 Years
Discussion Span
Last Post by Hilariousity
0

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

bool Data::operator
0

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& ...
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.