#include "Includes.h"
enum BlowfishAlgorithm
{
ECB,
CBC,
CFB64,
OFB64,
};
class Blowfish
{
public:
struct bf_key_st
{
unsigned long P[18];
unsigned long S[1024];
};
Blowfish(BlowfishAlgorithm algorithm);
void Dispose();
void SetKey(unsigned char data[]);
unsigned char Encrypt(unsigned char buffer[]);
unsigned char Decrypt(unsigned char buffer[]);
char EncryptIV();
char DecryptIV();
private:
BlowfishAlgorithm _algorithm;
unsigned char _encryptIv[200];
unsigned char _decryptIv[200];
int _encryptNum;
int _decryptNum;
};
class GameCryptography
{
public:
Blowfish _blowfish;
GameCryptography(unsigned char key[]);
void Decrypt(unsigned char packet[]);
void Encrypt(unsigned char packet[]);
Blowfish Blowfish;
void SetKey(unsigned char k[]);
void SetIvs(unsigned char i1[],unsigned char i2[]);
};
GameCryptography::GameCryptography(unsigned char key[])
{
}
Error:IntelliSense: no default constructor exists for class "Blowfish" ???!
This question is related to
c++
class
constructor
class-design
default-constructor
A default constructor is a constructor that either has no parameters, or if it has parameters, all the parameters have default values.
Because you have this:
Blowfish(BlowfishAlgorithm algorithm);
It's not a default constructor. The default constructor is one which takes no parameters. i.e.
Blowfish();
You declared the constructor blowfish as this:
Blowfish(BlowfishAlgorithm algorithm);
So this line cannot exist (without further initialization later):
Blowfish _blowfish;
since you passed no parameter. It does not understand how to handle a parameter-less declaration of object "BlowFish" - you need to create another constructor for that.
Source: Stackoverflow.com