Working on a solitare program in C++

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 583 Views - Last Post: 30 November 2017 - 07:06 AM Rate Topic: -----

#16 Failing Calculus  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 23
  • Joined: 07-March 16

Re: Working on a solitare program in C++

Posted 29 November 2017 - 05:23 PM

I really cant thank you guys enough, I still have a ways to go, but I now understand why code re-usability is so key in projects like this. It was faster just to hard code everything at first, but once I got everything into functions I was able to progress way quicker than I imagined i'd be able to. One question I have in regards to my plans from here, do I really even need to use queues and deques? Vectors can accomplish everything I need right? I've divided the full deck vector into two vectors, one for the Draw pile, and one for the Hand pile(cards on board), and then the hand pile into 7 separate vectors to represent each pile of cards. Wouldn't it be easier to move cards from one pile to the next with vectors? I'm thinking about using pop on the vector the cards is to be removed from, and then placing it on the next vector with push_front, for the draw pile I could also use pop and then push_back to put it back on the bottom right?
Was This Post Helpful? 0
  • +
  • -

#17 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon


Reputation: 7070
  • View blog
  • Posts: 14,746
  • Joined: 16-October 07

Re: Working on a solitare program in C++

Posted 30 November 2017 - 07:06 AM

View PostFailing Calculus, on 29 November 2017 - 07:23 PM, said:

do I really even need to use queues and deques?

Nope. That's an implementation detail. Again, think about the methods you'll need.

View PostFailing Calculus, on 29 November 2017 - 07:23 PM, said:

Vectors can accomplish everything I need right?

Indeed. It is the first, and sometimes only, collection class C++ programmers reach for, for better or worse.

Or course, you can also accomplish everything with an array, but you'd need to write more code, and probably get distracted by that logic instead of the program itself. Ideally, as a programmer, you should know how to write things like std::vector from scratch: and then not have to.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2