I'm getting the error for the following code "error C2664: 'KaibaMainPhase' : cannot convert parameter 1 from 'void (__cdecl *[2])(std::vector<_Ty> &,std::vector<_Ty> &,std::vector<std::vector<_Ty>> &,std::vector<_Ty> &,std::vector<_Ty> &)' to 'void (__cdecl *)(std::vector<_Ty> &,std::vector<Card> &,std::vector<Card> &)"

class Card
{
public:
	string GetName() {return Name;}
	void SetName(const string& setName) {Name = setName; } 
	void SetType(const string& setType) {Type = setType; }

private:
	string Name;
	string Type;
};

vector< vector<Card> > Field(4, vector<Card>(5));
vector<Card> KaibaHand;
vector<Card>::iterator KH;
vector<Card> YugiHand;
vector<Card>::iterator YH;

vector<Card> KaibaGraveyard;
vector<Card>::iterator KG;
vector<Card> YugiGraveyard;
vector<Card>::iterator YG;


void KaibaBeginning(vector<Card> &KaibaHand, vector<Card> &KaibaDeck);
void DrawForKaiba(vector<Card> &KaibaHand, vector<Card> &KaibaDeck);
void KaibaMainPhase(void (*)(vector< vector<Card> > &Field, vector<Card> &KaibaGraveyard, vector<Card> &YugiGraveyard), vector<Card> &KaibaHand, vector<Card> &KaibaDeck, vector< vector<Card> > &Field, vector<Card> &YugiGraveyard, vector<Card> &KaibaGraveyard);


void FieldFunction(vector< vector<Card> > &Field);
void KaibaHandFunction(vector<Card> &KaibaHand);
void KaibaGraveyardFunction(vector<Card> &KaibaGraveyard);
void YugiGraveyardFunction(vector<Card> &YugiGraveyard);
void KaibaSummon(vector< vector<Card> > &Field, vector<Card> &KaibaHand, int HandNumber, int MonstCount);
void YugiSummon(vector< vector<Card> > &Field, vector<Card> &YugiHand, int HandNumber, int MonstCount);
void KaibaDiscard(int HandNumber, vector<Card> &KaibaHand, vector<Card> &KaibaGraveyard);
void YugiDiscard(int HandNumber, vector<Card> &YugiHand, vector<Card> &YugiGraveyard);


void KaibaMainPhase(void (*)(vector< vector<Card> > &Field, vector<Card> &KaibaGraveyard, vector<Card> &YugiGraveyard), vector<Card> &KaibaHand, vector<Card> &KaibaDeck, vector< vector<Card> > &Field, vector<Card> &YugiGraveyard, vector<Card> &KaibaGraveyard);
 

void HEAVYSTORM(vector<Card> &KaibaHand, vector<Card> &KaibaDeck, vector< vector<Card> > &Field, vector<Card> &KaibaGraveyard, vector<Card> &YugiGraveyard)
	{
	cout<<"This card destroys ALL magic and traps cards on the field!!"<<endl;
		for (int i=0; i<5; i++)
		{
			YugiGraveyard.push_back(Field[0][i]);
		Field[0][i]=Card();
			KaibaGraveyard.push_back(Field[3][i]);
			Field[3][i]=Card();
		}	
	}

void POTOFGREED(vector<Card> &KaibaHand, vector<Card> &KaibaDeck, vector< vector<Card> > &Field, vector<Card> &KaibaGraveyard, vector<Card> &YugiGraveyard)
{
	DrawForKaiba(KaibaHand, KaibaDeck);
}


int main()
{

void (* pFunct[2]) (vector<Card> &KaibaHand, vector<Card> &KaibaDeck, vector< vector<Card> > &Field, vector<Card> &KaibaGraveyard, vector<Card> &YugiGraveyard);
	pFunct[0] = HEAVYSTORM;
	pFunct[1] = POTOFGREED;


KaibaMainPhase(pFunct, KaibaHand, KaibaDeck, Field, YugiGraveyard, KaibaGraveyard);
}


void KaibaMainPhase( void (*pFunct)(vector<Card> &KaibaHand, vector<Card> &KaibaDeck, vector< vector<Card> > &Field, vector<Card> &KaibaGraveyard, vector<Card> &YugiGraveyard), vector<Card> &KaibaHand, vector<Card> &KaibaDeck, vector< vector<Card> > &Field, vector<Card> &YugiGraveyard, vector<Card> &KaibaGraveyard)
{
pFunct(KaibaHand, KaibaDeck, Field, KaibaGraveyard, YugiGraveyard);
}

void KaibaHandFunction(vector<Card> &KaibaHand)
{
		cout<<endl<<"Kaiba's hand contains: "<<endl;
		for (KH=KaibaHand.begin(); KH<KaibaHand.end(); KH++)
		{
			cout<<KH->GetName()<<endl;

		}
}

void YugiHandFunction(vector<Card> &YugiHand)
{
		cout<<endl<<"Yugi's hand contains: "<<endl;
		for (YH=YugiHand.begin(); YH<YugiHand.end(); YH++)
		{
			cout<<YH->GetName()<<endl;

		}
}

void KaibaGraveyardFunction(vector<Card> &KaibaGraveyard)
{
			cout<<endl<<"Kaiba's graveyard contains: "<<endl;
			for (KG=KaibaGraveyard.begin(); KG<KaibaGraveyard.end(); KG++)
			{
				cout<<KG->GetName()<<endl; //SAME AS (*gt).GetName
			}
			cout<<"\n";
}

void YugiGraveyardFunction(vector<Card> &YugiGraveyard)
{
			cout<<endl<<"Yugi's graveyard contains: "<<endl;
			for (YG=YugiGraveyard.begin(); YG<YugiGraveyard.end(); YG++)
			{
				cout<<YG->GetName()<<endl; //SAME AS (*gt).GetName
			}
			cout<<"\n";
}

Edited 5 Years Ago by cypherscouter13: n/a

void KaibaMainPhase(void (*)(vector< vector<Card> > &Field, vector<Card> &KaibaGraveyard, vector<Card> &YugiGraveyard), vector<Card> &KaibaHand, vector<Card> &KaibaDeck, vector< vector<Card> > &Field, vector<Card> &YugiGraveyard, vector<Card> &KaibaGraveyard);

What are you trying to accomplish with void (*)??

I only want KaibaMainPhase to call how ever many arrays the user asks for. So if the user only wants one, I want KaibaMainPhase to call pFunct[0] or pFunct[1]. But if I try the code below, I get the same error

void KaibaMainPhase( void (*pFunct)(vector<Card> &KaibaHand, vector<Card> &KaibaDeck, vector< vector<Card> > &Field, vector<Card> &KaibaGraveyard, vector<Card> &YugiGraveyard), vector<Card> &KaibaHand, vector<Card> &KaibaDeck, vector< vector<Card> > &Field, vector<Card> &YugiGraveyard, vector<Card> &KaibaGraveyard)
{
int HandNum;
cout<<"Enter a number: "<<endl;
cin>>HandNum;
cout<<"You played "<<Field[3][HandNum-1].GetName();
pFunct[HandNum-1](KaibaHand, KaibaDeck, Field, KaibaGraveyard, YugiGraveyard);//
}

Edited 5 Years Ago by cypherscouter13: n/a

This article has been dead for over six months. Start a new discussion instead.