标签:ring ace cout rds clu out card game color
#include<iostream> #include<memory> using namespace std; class PokerGame{ public: int cards; int mumber; string name; PokerGame(int cards, int mumber){ this->cards = cards; this->mumber = mumber; } void display(){ cout << "cards: " << cards<<" mumber: " << mumber<<" name: " << name<<endl; } }; void Game(shared_ptr<PokerGame> game){ // 智能指针做形参 game->display(); game->cards=45; game->mumber=5; game->name="钓鱼"; game->display(); } int main(){ shared_ptr<PokerGame> game= make_shared<PokerGame>(54,3); game->name = "斗地主"; Game(game); shared_ptr<PokerGame> game2(new PokerGame(30,2)); game2->name = "随便玩"; game2->display(); return 0; }
标签:ring ace cout rds clu out card game color
原文地址:https://www.cnblogs.com/ligei/p/11461204.html