user1275488
user1275488

Reputation: 3

Reference QList Inherited from Derived Class

If have a class, Book, that just inherited QList< char >, I am wondering if it is possible to reference the QList from within Book?

For example, if I want to iterate through element in the QList, how would I do so? Below is the code of how I would do this if Book did not inherit QList.

QList<char> list;

foreach (char element, list) {
    cout << element << endl;
}

Upvotes: 0

Views: 541

Answers (1)

Davita
Davita

Reputation: 9114

foreach(char element, *this) {
    cout << element << endl;
}

BTW, I'm not sure what you are trying to achieve but I guess this is a case where you should favor composition over inheritance.

Upvotes: 2

Related Questions