Jump to content
  • Advertisement
Sign in to follow this  
goonst

Using insert on a vector

This topic is 4769 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know this is a really easy thing but I'm just a beginner. Hopefully someone can easily steer me in the right direction. I'm making a Blackjack game and I'm trying to insert a cut card into a deck (which is a vector of cards) at a specific spot. Here's the function. void Shoe::insertCutCard(void) { Card cutCard; int iRandomNum = rand(); int iFifthOfDeck = vCards.size() * (1/5); int iSeventhOfDeck = vCards.size() * (1/7); cutCard.iSuit = 0; cutCard.iValue = 0; cutCard.bFacingUp = false; int iCutPos = (iRandomNum % (iFifthOfDeck - iSeventhOfDeck) + iFifthOfDeck); vCards.insert(iCutPos, cutCard); } I believe that I need to use a iterator when using insert but I cant find a good way to make an interator equal iCutPos. Any help on the matter would be much appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!