我正在编写扑克游戏的代码,但我有问题找出一种方法来传递类对象的值..在这种情况下类卡..对象卡组。 。我想这样做是为了模拟向玩家交付5张牌。我创建了另一个类型为card1的对象,所以在创建套牌后,然后洗牌。我想从对象中抽取5张牌甲板......并将其传递给对象player1 ..通过引用传递值,但仍显示地址不是值
但是,当我打印屏幕上看到值是否通过我只获取单元格的地址..不是值。 下面是代码
code for class deck
[代码]
class Card
{
public:
int face;
int suit;
void toString() {
cout<<FaceString[face]<<" of "<<SuitString[suit]<<endl;
}
};
[/代码]
code for class of deal
[代码]
class deal
{
public:
Card deck[52];
void toDisplay(){
for (int j = 0; j < 5; j++) {
cout<<"player card "; deck[j].toString();
}
}
};
[\代码]
[代码]
//creation of both objects
Card deck[52];
Card player1[5];
[/代码}
in main
player1.deck; <<==[Error] request for member 'deck' in 'player1', which is of non-class type 'deal [5]'
您已经错过了一个星号。投票结束为错字。 – dasblinkenlight
@ dasblinkenlight ..谢谢..我知道这将是简单的... – Darius