Hey again! I've asked a question here once and have been lurking ever since. I was working on a new program and have come across problem. I don't really know what's wrong so I assume I overloaded something. The problem is in this snip of code

for(int m=0; m<num+1; m++)
	{
		if((intarray[m]>begllts) && (intarray[m]<endllts));
		{
			cout << dubarray[m] << "C" << stringarray[m];
			total += intarray[m];
			count ++;
		}
	}

intarray, dubarray, and stringarray are all Dynamic arrays.
The error is:
error: no match for ‘operator>’ in ‘*(intarray + ((unsigned int)(((unsigned int)m) * 8u))) < begllts’

error: no match for ‘operator<’ in ‘*(intarray + ((unsigned int)(((unsigned int)m) * 8u))) < endllts’


I can post more code if needed, but I haven't commented it yet. I usually keep my pseudocode separate from my program until the finished product so I don't get confused in all my comments :)

Thanks in advance!
(As always, I'd prefer if you show me or trick me into how I can fix it rather than giving me the code. I love coding and want to learn everything, not just have someone do it for me)

Recommended Answers

All 5 Replies

Could we see the definitions of the classes in your dynamic arrays?

Sorry for lack of comments.

long long int llints, total;
	double *dubarray = new double[size];
	string *stringarray = new string[size];
	long long int *intarray = new long long int[size];
while(fin >> ts)
	{
		fin >> temp;
		if(size==num)
		{
			int oldsize = size;
			resize(dubarray, size);
			size = oldsize;
			resize(stringarray, size);
			size = oldsize;
			resize(intarray, size);
		}
		dubtemp = F2C(temp);
		dubarray[num]= dubtemp;
		llints = TS2INT(ts);
		intarray[num] = llints;
		humants = TS2HRTS(ts);
		stringarray[num] = humants;
		num++;
void resize(double *&dubarray, int &size)
{
	double *newarray = new double[size+5];
	for(int i=0; i<size; i++)
	{
		newarray[i]=dubarray[i];
	}
	delete[] dubarray;
	size+=5;
	dubarray = newarray;

}

This problem is just a matter of the types of "intarray" and "begllts and endllts". If they are of the same type (or compatible types), then you need to show the definition of those types. If they are the same and are primitive types like "int", then there is something wrong. Most likely, the types are not built-in types and you didn't provide an overload for the < > operators. Normally, a custom type would need to provide the compiler with a method to compare them (if you want to compare them and if it makes sense to do so), for example:

struct MyIntType {
  int value;

  bool operator < (const MyIntType& rhs) const {
    return value < rhs.value;
  };
  bool operator > (const MyIntType& rhs) const {
    return value > rhs.value;
  };
};

In the above, the definitions of operators < > will tell the compiler how to handle less-than or greater-than comparisons between variables of type "MyIntType".

If your intarray is of type "long long int", I'm guessing that "begllts" and "endllts" are not. You should ask yourself why you are comparing values of different type. Maybe "begllts" and "endllts" should also be of type "long long int", or maybe the comparison is not logical, or maybe the variables simply need to be cast to "long long int" before, as so "(long long int)(begllts)".

If your intarray is of type "long long int", I'm guessing that "begllts" and "endllts" are not. You should ask yourself why you are comparing values of different type. Maybe "begllts" and "endllts" should also be of type "long long int", or maybe the comparison is not logical, or maybe the variables simply need to be cast to "long long int" before, as so "(long long int)(begllts)".

Yeah... I thought of that but never looked up. I accidentally put them as string when I knew they needed to be long long ints... but now I'm getting a segmentation fault...

Thank you :)

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.