Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8882875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:41:00+00:00 2026-06-14T20:41:00+00:00

I am programming in C++ and cant figure out how to access the STL

  • 0

I am programming in C++ and cant figure out how to access the STL container in a parent class. I have the following classes:

class Card
class CardPile : private vector<Card*>
class Deck : public CardPile{Foo()}

I know that if Foo() was in CardPile class I can call vector’s size with size(). How would I call vector’s size() function from Foo().

EDIT: Unfortunately, I am not allowed to change any of the class definitions

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:41:02+00:00Added an answer on June 14, 2026 at 8:41 pm

    size() is a private method of CardPile, but you could, it if suits the design, make it public or protected:

    class CardPile : private std::vector<Card*>
    {
     public: // or protected
      using std::vector<Card*>::size;
    };
    

    This will allow you to call size() either everywhere (public) or from derived classes (protected).

    But bear in mind that standard library containers are not designed to be inherited from, specially publicly. So you could change your CardPile class to hold a std::vector<Card*> data member. And after that, you may look into holding smart pointers in the vector if you are currently dealing with dynamically allocated Card objects.

    class CardPile : 
    {
     public: // or protected
      std::vector<Card*>::size_type size() const { return cards_.size(); }
     private: 
      std::vector<Card*> cards_
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just getting into XNA programming and have been unable to figure out
I'm new to iPhone programming and can't figure out how to use Core Graphics.
I'm studying programming language theory and I can't figure out a solid reason why
I am new at ios programming and I need some help, can't figure out
I'm a programming newbie, and I can't figure out how to store a function
I've been trying to figure this out for a while and I just cant
I have an issue i couldn't figure out so far. I googled and searched
I can't figure out the principles of dynamic programming and I really do want
I have an assignment in a C programming class to output a poem with
Im programming in C#.NET. I want to create a nested class that can access

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.