编译器错误与"operator =="不匹配 [英] compiler error no match for 'operator=='

查看:91
本文介绍了编译器错误与"operator =="不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白为什么会收到此错误.
这是我的代码.

I don''t understand why I am getting this error.
Here is my code.

#include<iostream>
#include<string>
#include<fstream>
#include<iomanip>
#include<stdlib.h>


using namespace std;

enum CCType{ VISA, MASTERCARD, INVALID };
int const LINEMAXIMUM = 60;
int const CCNUMBERLENGTH = 16;

CCType validate (string aCreditCardNumber);

int main ()
{
	ifstream myIn;
	string aCreditCardNumber;
	float amount;
	string filename;
	string VISA[LINEMAXIMUM];
	string MASTERCARD[LINEMAXIMUM];
	string INVALID[LINEMAXIMUM];
	float VISAamt[LINEMAXIMUM];
	float MASTERCARDamt[LINEMAXIMUM];
	float INVALIDamt[LINEMAXIMUM];
	CCType type;
	CCType Cardtype;
	
	int l=0;
	int m=0;
	int n=0;
	
	
	cout <<"What is the name of the file"<< endl;
	cin >>filename;
	myIn.open("dataset.txt");
	
	while (filename!="dataset.txt")
	{	
	cout <<"File does not exist"<<endl<<"What is the name of the file"<<endl;
	cin >> filename;
	}
	
	while (myIn)
		
	{  
		myIn >> aCreditCardNumber >> amount;
		//Cardtype = validate(aCreditCardNumber);
		if (Cardtype == VISA)
		{
			VISA[l]=aCreditCardNumber;
			VISAamt[l]=amount;
			l++;
		}
		if (Cardtype == MASTERCARD)
		{
			MASTERCARD[m]=aCreditCardNumber;
			MASTERCARDamt[m]=amount; 
			m++;
		}
		if (Cardtype == INVALID)
		{
			INVALID[n]=aCreditCardNumber;
			INVALID[n]=amount;
			n++;
		}
		
	}
	myIn.close();
	

	
	
	
	
	
	
	
	
	
return 0;
}	
CCType validate (string aCreditCardNumber)
{	CCType type;	bool checknum = true;
	int sumi=0;
	int sumj=0;
	int ccdigit=0;
	int jnum=0;
	int sumij=0;
	int credit[15];
	
		for (int i=1; i<=15; i=i+2)
			{ sumi= (aCreditCardNumber[i] - ''0'') + sumi;
			}
		for (int j=0; j<=15; j=j+2)
		{	jnum=(aCreditCardNumber[j] - ''0'') * 2;
			if (jnum<10)
			{	sumj= jnum+ sumj;
			}
		
			 else  sumj=((jnum%10)+1)+sumj;
		}	
			sumij=sumj+sumi;
			if (sumij%10!=0)
				checknum==true;
			if (sumij%10 !=0 || aCreditCardNumber.size()>16)
			{	checknum==false;
				
			}
			if (checknum==true)
			{
				if (aCreditCardNumber[0]==''4'')
				type = VISA;
		
				else if ((aCreditCardNumber[0]==''5'') && (aCreditCardNumber[1]==''1'' || ''2'' || ''3'' || ''4'' || ''5''))
					type = MASTERCARD;
				
			
				else type = INVALID;
			}
return type;
}

推荐答案


您的VISA等.标识符不明确.
将枚举标识符更改为
Hi,
Your VISA etc.. identifiers are ambiguous.
Change the enum identifiers to
enum CCType{ e_VISA, e_MASTERCARD, e_INVALID };


并在相关的地方使用它们,例如:


and use them where relevant, for instance:

if (Cardtype == e_VISA)
{
    VISA[l]=aCreditCardNumber;
    VISAamt[l]=amount;
    l++;
}


您的代码将正确编译,仍然无法操作.
欢呼声,
AR


Your code will compile without error, still far from operational.
cheers,
AR


感谢编译,但是仍然需要工作,但我感谢您的帮助.
Thanks it does compile but it still needs work but i appreciate your help.


这篇关于编译器错误与"operator =="不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆