Thread: Not able to access private data members

  1. #31
    diligentStudent()
    Join Date
    Apr 2002
    Posts
    79
    I'll continue to try my best to solve this complex problem.

  2. #32
    diligentStudent()
    Join Date
    Apr 2002
    Posts
    79
    This doesn't seem to work:
    Code:
    class BunchOfCards
    {
      public:
        Card DealACard();
        friend ifstream& operator >>(ifstream& ifs, BunchOfCards& bcds);
        friend ostream& operator <<(ostream& ofs, BunchOfCards bcds);
      private:
        vector <Card> mSomeCards;
    };
    
    Card BunchOfCards::DealACard()
    {
      Card b, targetPosition;
      targetPosition=mSomeCards.size();
      for(int i=targetPosition;i<mSomeCards.size();i++)
      {
        mSomeCards[i]=mSomeCards[i+1];
      }
      mSomeCards.pop_back();
      return b;
    }
    Now, I'm trying to do something here, and I know that I am not doing it right. I've got to start somewhere, so I have. I have been instructed to:
    Consider that the last card pushed back onto the vector is the "top" of the BunchOfCards. Write a member function that takes the top card off of BunchOfCards.
    ...Returns the top card and takes the card out of the bunch of cards.
    I am a bit lost here as well. Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 10:13 AM
  2. Question with accessing private data
    By mikahell in forum C++ Programming
    Replies: 3
    Last Post: 01-18-2008, 03:14 AM
  3. Need help with calculator program
    By Kate in forum C# Programming
    Replies: 1
    Last Post: 01-16-2004, 10:48 AM
  4. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM