Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing methods of class which extends vector?

Status
Not open for further replies.

JediDan

Programmer
May 15, 2002
128
US
Hello,

I have a class:
Code:
class Deck : vector<Card*>

When I try to access typical vector methods...
Code:
Card * c = new Card(...);
Deck myDeck;
myDeck.push_back(c);

I get an error: [tt]error C2247: 'std::vector<_Ty>::push_back' not accessible because 'Deck' uses 'private' to inherit from 'std::vector<_Ty>'[/tt]

I am creating the class because I want to be able to add additional operations on the vector, but obviously still want to access the native methods. What do I need to do?

Any suggestions appreciated.

Thanks.
 
private inheritance by default, use
Code:
class Deck : public vector<Card*>
STL classes are bad parents, avoid this. STL classes/templates describe completed functionality, use them as bricks, not as parents.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top