Reputation: 155
I have a class, Car, that inherits a QList< int >. I am wondering how would I use the QList I just inherited?
From my amateur understanding of how to use inheritance, if Car inherits Vehicle, I would access a method of Vehicle by going Vehicle::getWheels(). How would this work if I inherit QList though?
Upvotes: 0
Views: 1538
Reputation: 12920
If your Car inherits from Vehicle you can simply use the inherited methods (in case you have not overwritten those). Example:
class Vehicle
{
int wheels_;
public:
Vehicle(int wheels=4)
: wheels_(wheels)
{
}
int getWheels() const { return wheels_; }
};
class Car: public Vehicle
{
};
Car myCar;
myCar.getWheels();
So for your question, you can simply use the members of QList< int >
without being explicit if your class was decleared as class Car : public QList< int > { ... };
.
Upvotes: 1