-
January 11th, 2011, 09:13 AM
#1
error c2664
Hi
I`m new at programming Visual C++ and trying to make a card game but don`t understand how to sovle the error I got. The error says: error C2664: 'BlackJackKase::Form1::showTrumpCards' : cannot convert parameter 1 from 'BlackJackKase::Form1::Trump ^' to 'BlackJackKase::Form1::Trump'.
Could someone help me please.
code:
ref class Trump
{
public:
int num;
char type;
Trump(int i, char c) {num = i; type = c;}
};
void showTrumpCards(Trump t, int p1, int p2)
{
if(t.type == 'c'){
switch(t.num){
case 1:
pictureBoxTrumpC1->Location = Point(p1, p2);
pictureBoxTrumpC1->Visible = "True";
break;
case 2:
pictureBoxTrumpC2->Location = Point(p1, p2);
pictureBoxTrumpC2->Visible = "True";
break;
case 3:
pictureBoxTrumpC3->Location = Point(p1, p2);
pictureBoxTrumpC3->Visible = "True";
}
}
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
//Create a Deck with 52 cards
array<Trump^>^ TrumpCards = gcnew array<Trump^>{
gcnew Trump(1,'c'), gcnew Trump(2,'c'),
gcnew Trump(3,'c'), gcnew Trump(4,'c'),
gcnew Trump(5,'c'), gcnew Trump(6,'c'),
gcnew Trump(7,'c'), gcnew Trump(8,'c'),
gcnew Trump(9,'c'), gcnew Trump(10,'c'),
gcnew Trump(11,'c'), gcnew Trump(12,'c'),
gcnew Trump(13,'c'), gcnew Trump(1, 's'),
gcnew Trump(2, 's'), gcnew Trump(3, 's'),
gcnew Trump(4, 's'), gcnew Trump(5, 's'),
gcnew Trump(6, 's'), gcnew Trump(7, 's'),
gcnew Trump(8, 's'), gcnew Trump(9, 's'),
gcnew Trump(10, 's'), gcnew Trump(11, 's'),
gcnew Trump(12, 's'), gcnew Trump(13, 's'),
gcnew Trump(1, 'd'), gcnew Trump(2, 'd'),
gcnew Trump(3, 'd'), gcnew Trump(4, 'd'),
gcnew Trump(5, 'd'), gcnew Trump(6, 'd'),
gcnew Trump(7, 'd'), gcnew Trump(8, 'd'),
gcnew Trump(9, 'd'), gcnew Trump(10, 'd'),
gcnew Trump(11, 'd'), gcnew Trump(12, 'd'),
gcnew Trump(13, 'd'), gcnew Trump(1, 'h'),
gcnew Trump(2, 'h'), gcnew Trump(3, 'h'),
gcnew Trump(4, 'h'), gcnew Trump(5, 'h'),
gcnew Trump(6, 'h'), gcnew Trump(7, 'h'),
gcnew Trump(8, 'h'), gcnew Trump(9, 'h'),
gcnew Trump(10, 'h'), gcnew Trump(11, 'h'),
gcnew Trump(12, 'h'), gcnew Trump(13, 'h')
};
showTrumpCards(TrumpCards[0], 312, 372);
}
-
January 11th, 2011, 10:55 AM
#2
Re: error c2664
Your code is managed C++, not Visual C++. Try posting your question here.
-
January 12th, 2011, 09:17 AM
#3
-
January 12th, 2011, 10:18 AM
#4
Re: error c2664
I seriously doubt that there is any way to pass a reference type by value at all. Besides that, the type of TrumpCards[0] in
Code:
showTrumpCards(TrumpCards[0], 312, 372);
is Trump ^, not Trump. Therefore, the signature of showTrumpCards() needs to be changed to
Code:
void showTrumpCards(Trump ^t, int p1, int p2)
And, of course, in turn the two references to Trump members in this function need to be changed to
Code:
if(t->type == 'c'){
switch(t->num){
// ...
}
}
HTH
Please use code tags when posting code.
Ah, and... Welcome to CodeGuru!
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|