creditverification.cpp

来自「Visual_C++[1].NET_Bible1 Visual_C++宝典书中」· C++ 代码 · 共 43 行

CPP
43
字号
// CreditVerification.cpp 
#include "stdafx.h"

#define _DLL
#include "creditverification.h"

BOOL APIENTRY DllMain(HANDLE hModule,
	DWORD  ul_reason_for_call, LPVOID lpReserved)
{
    return TRUE;
}

class CCreditVerification : public ICreditVerification
{
private:
	enum CardType {Visa, MasterCard, Amex} m_type;
public:
	void SetCardType(char* s)
	{
		if (0 == strcmp("Visa", s))
			m_type = Visa;
		else if (0 == strcmp("MasterCard", s))
			m_type = MasterCard;
		else m_type = Amex;
	}
	bool VerifyCardNumber(long n) 
	{
		if (m_type == Visa)
			return (n % 2);
		else if (m_type == MasterCard)
			return (n % 3);
		else if (m_type == Amex)
			return (n % 5);
		else return false;
	}
};

DLLSPEC ICreditVerification* GetCreditVerificationObject()
{
	return new CCreditVerification;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?